Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic After version update serialization on ContainerNode fails (Read 6813 times)
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
After version update serialization on ContainerNode fails
Dec 6th, 2016 at 10:07am
Print Post  
After update to 5.7v, Container node serialization fails in older version it worked fine, but now get
"object not set to an instance of an object" error.
I debuged the code and I saw that ContainerNode is initialized and it is not null.

Maybe in the new version serialization changed, or I need to set all the properties?

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: After version update serialization on ContainerNode fails
Reply #1 - Dec 6th, 2016 at 10:37am
Print Post  
Is this when saving files, or posting the page from client to server? Please post the exception's stack frame.
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: After version update serialization on ContainerNode fails
Reply #2 - Dec 6th, 2016 at 10:56am
Print Post  
Slavcho wrote on Dec 6th, 2016 at 10:37am:
Is this when saving files, or posting the page from client to server? Please post the exception's stack frame.


It's when loading Diagram.

Here is StackTrace:

PS. I adjusted paths in this StackTrace string.

Code
Select All
System.NullReferenceException was unhandled by user code
  Message=Object reference not set to an instance of an object.
  Source=MindFusion.Diagramming.WebForms
  StackTrace:
       at MindFusion.Diagramming.WebForms.ContainerNodeConverter.Serialize(Object obj, JavaScriptSerializer serializer)
       at .MyContainerNodeConverter.Serialize(Object obj, JavaScriptSerializer serializer) in \MyContainerNodeConverter.cs:line 40
       at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable enumerable, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.SerializeDictionary(IDictionary o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)
       at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj)
       at A.c11941951d1a217fe413d2aa0601bfabd.c9ae54d4cf6e8dfc48963e271f4f702cf(DiagramView c5c59c6a4a2a6c4948790bb75e068d36f)
       at A.c11941951d1a217fe413d2aa0601bfabd.c00fc1112717cfb59d7e43625eec0e867(DiagramView c3d2ea328bcae2cddab9c206fcedee40b, HtmlTextWriter c524c2562131a57a50f76b26b267fbde6)
       at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
       at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Page.Render(HtmlTextWriter writer)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: After version update serialization on ContainerNode fails
Reply #3 - Dec 6th, 2016 at 11:32am
Print Post  
Are you passing non-null DiagramView reference to the converter when registering it and when calling base constructor?
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: After version update serialization on ContainerNode fails
Reply #4 - Dec 6th, 2016 at 12:12pm
Print Post  
Slavcho wrote on Dec 6th, 2016 at 11:32am:
Are you passing non-null DiagramView reference to the converter when registering it and when calling base constructor?


Yes. It previously worked.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: After version update serialization on ContainerNode fails
Reply #5 - Dec 6th, 2016 at 12:44pm
Print Post  
This is ContainerNodeConverter's code, check if the arguments you are passing to it are non-null and maybe verify node.CaptionFormat is != null; ContainerNode's constructor always sets the latter.

Code
Select All
public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
{
    serializer.RegisterConverters(new JavaScriptConverter[] { new SizeConverter() });

    IDictionary<string, object> json = base.Serialize(obj, serializer);
    ContainerNode node = (ContainerNode)obj;

    if (view == null || view.ClientSideMode == ClientSideMode.Canvas)
    {
        if (view == null)
        {
            json.Add("type", node.GetType().ToString());
        }

        json.Add("text", node.Caption);
        json.Add("captionHeight", node.CaptionHeight);
	json.Add("captionBackBrush", node.CaptionBackBrush);
	json.Add("textAlignment", node.CaptionFormat.Alignment);
	json.Add("lineAlignment", node.CaptionFormat.LineAlignment);
        json.Add("margin", node.Margin);
        json.Add("foldable", node.Foldable);
        json.Add("folded", node.Folded);
        json.Add("unfoldedSize", node.UnfoldedSize);
        json.Add("clipChildren", node.ClipChildren);
        json.Add("allowAddChildren", node.AllowAddChildren);
        json.Add("allowRemoveChildren", node.AllowRemoveChildren);
        json.Add("shape", node.Shape);
    } 



I can't see anything else that could throw NullReferenceException.
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: After version update serialization on ContainerNode fails
Reply #6 - Dec 6th, 2016 at 1:33pm
Print Post  
Slavcho wrote on Dec 6th, 2016 at 12:44pm:
This is ContainerNodeConverter's code, check if the arguments you are passing to it are non-null and maybe verify node.CaptionFormat is != null; ContainerNode's constructor always sets the latter.

Code
Select All
public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
{
    serializer.RegisterConverters(new JavaScriptConverter[] { new SizeConverter() });

    IDictionary<string, object> json = base.Serialize(obj, serializer);
    ContainerNode node = (ContainerNode)obj;

    if (view == null || view.ClientSideMode == ClientSideMode.Canvas)
    {
        if (view == null)
        {
            json.Add("type", node.GetType().ToString());
        }

        json.Add("text", node.Caption);
        json.Add("captionHeight", node.CaptionHeight);
	json.Add("captionBackBrush", node.CaptionBackBrush);
	json.Add("textAlignment", node.CaptionFormat.Alignment);
	json.Add("lineAlignment", node.CaptionFormat.LineAlignment);
        json.Add("margin", node.Margin);
        json.Add("foldable", node.Foldable);
        json.Add("folded", node.Folded);
        json.Add("unfoldedSize", node.UnfoldedSize);
        json.Add("clipChildren", node.ClipChildren);
        json.Add("allowAddChildren", node.AllowAddChildren);
        json.Add("allowRemoveChildren", node.AllowRemoveChildren);
        json.Add("shape", node.Shape);
    } 



I can't see anything else that could throw NullReferenceException.



I have old xml that is created in silvelight. "<Diagram Version="12">", would that be an issue, maybe there is new properties, that we need to set?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: After version update serialization on ContainerNode fails
Reply #7 - Dec 6th, 2016 at 1:48pm
Print Post  
Please attach it here zipped or email to support@mindfusion.eu
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: After version update serialization on ContainerNode fails
Reply #8 - Dec 6th, 2016 at 2:01pm
Print Post  
Slavcho wrote on Dec 6th, 2016 at 1:48pm:
Please attach it here zipped or email to support@mindfusion.eu


Found solution. Just applied styling and other properties after xml load, because, not all properties set in old xml version.
« Last Edit: Dec 7th, 2016 at 6:49am by CrushJelly »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint