A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Error deserializing PropertyLinkCollection after upgrade to R2.

Vote:
 

We are currently upgrading a site from CMS 6 to CMS 6 R2. The site has a couple of Dynamic Content's that uses BinaryFormatter to serialize/deserialize entire objects containing property type definitions and values for it's State.

Below is a simplified example of how the different Dynamic Contents are structured;

1) The Dynamic Content definition;

public class PageListDynamicContent : IDynamicContent
{
    public PageListDynamicContentData PageListDynamicContentData { get; set; }

    // More methods here, deleted for simplicity

    public string State
    {
        get
        {
            if (PageListDynamicContentData == null)
                return null;

            using (var stream = new MemoryStream())
            {
                new BinaryFormatter().Serialize(stream, PageListDynamicContentData);
                return Convert.ToBase64String(stream.ToArray());
            }
        }
        set
        {
            if (value == null)
                return;

            using (var stream = new MemoryStream(Convert.FromBase64String(value)))
            {
                stream.Position = 0;
                PageListDynamicContentData = new BinaryFormatter().Deserialize(stream) as PageListDynamicContentData;
            }
        }
    }
}

    

2) The PageListDynamicContentData-class;

[Serializable]
public class PageListDynamicContentData
{
    public PropertyPageReference ParentPage { get; set; }
    public PropertyLinkCollection ManualPages { get; set; }
    public PropertyNumber MaxPageCount { get; set; }
    public PropertyNumber TeaserTextLength { get; set; }
}

     

When trying to deserialize (in PageListDynamicContent.set_State(String value)) a "NullReferenceException" is thrown with the following stack trace;

at EPiServer.SpecializedProperties.PropertyXhtmlString.System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(Object sender)
at System.Runtime.Serialization.DeserializationEventHandler.Invoke(Object sender)
at System.Runtime.Serialization.ObjectManager.RaiseDeserializationEvent()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
...on to application stack trace...

The property throwing this seems to be the PropertyLinkCollection (which inherits PropertyXhtmlString). The only change I can find that possible could be the cause is the change in how the constructors in PropertyLinkCollection has changed to now be able to take a IPermanentLinkMapper. On the other hand the empty constructor sets _linkMapper to a new PermanentLinkMapper.

I'm at a loss here and would appreciate any help.

#54996
Nov 14, 2011 18:42
Vote:
 

Hi Rickard,

You might be affected by this bug -> #70463: Serialzed Xhtml property is missing serialized data 

Please get in contact with EPiServer support for a hotfix.

#54998
Nov 15, 2011 8:40
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.