문제

I have a custom webpart that was defined with a property like

[Personalizable(PersonalizationScope.Shared), WebBrowsable(true), WebDisplayName("Chart Type"), Category("Chart - Required")]
[InitializationParameterName("ySeriesType")]
public DataSeries1 YSeriesType { get; set; }

which has been deployed. I then changed it to:

[Personalizable(PersonalizationScope.Shared), WebBrowsable(true), WebDisplayName("Chart Type"), Category("Chart - Required")]
[InitializationParameterName("ySeriesType")]
public YSeriesType YSeriesType { get; set; }

This change now causes an error suggesting DataSeries1 was not found. How can I handle the upgrade for this scenario? Fwiw, the following IVersioningPersonalizable did not seem to work:

void IVersioningPersonalizable.Load(IDictionary unknownProperties)
{
    if (unknownProperties == null)
        return;

    _dirty = true;

    foreach (DictionaryEntry entry in unknownProperties)
    {
        switch (Convert.ToString(entry.Key))
        {
            case "YSeriesType":
                this.YSeriesType = (YSeriesType)Enum.Parse(typeof(YSeriesType), Convert.ToString(entry.Value));
                break;
        }
    }
}

protected override void OnInit(EventArgs e)
{
    if (_dirty && null != base.WebPartManager)
    {
        SetPersonalizationDirty();
        _dirty = false;
    }
}

Thanks!

도움이 되었습니까?

해결책

Your IVersioningPersonalizable code looks right, but I think SharePoint determines unknown properties by their name, and if property was not renamed - it will not be unknown...

So, could you please rename YSeriesType property and try to perform the upgrade again?

다른 팁

The error message is referring to the class DataSeries1, which is being used by the existing webpart. So, I'm guessing that you deleted (or renamed) this class.

After executing the code that updates the property values, then you can safely remove your DataSeries1 class.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top