Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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?

share|improve this answer
    
Yeah it seems like you'd have to leave the name alone; change the display name if it is a problem. –  Kit Menke May 13 '11 at 13:47
    
Yeah, I knew that I could rename to property a get my IVersionPersonalizable to work, I was hoping I could do a similar function but changing the type without renaming the property. Looks like I am going to have to rename the property to a new name if I am going to change the type. –  Mr. Young May 17 '11 at 19:42
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.