Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Error after LoadfromXML for Custom Shape node (Read 3996 times)
tusharpateluk
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 3rd, 2008
Error after LoadfromXML for Custom Shape node
Oct 1st, 2008 at 12:47pm
Print Post  
Hi,

I have extended Shape node with some additional data. Saving diagram to XML works fine. While load the save xml file it throws me error "Object reference not set to an instance of an object".
I had override LoadFromXML and was getting this error after LoadFromXML was successfully completed. After further research, I found that error was coming from Draw method that was executing after the LoadFromXML.

Can anyone please help me to fix this error. What exactly should I write in Draw method to fix this issue. Or their is any other solution.

Below is the stack trace of the error. Looking forward to your reply.

   at MindFusion.Text.Layout.x8a1888a014534b73(Int32 xb1c30745a1525188)
   at MindFusion.Text.Layout.Draw(Double xOff, Double yOff, RenderTextCallback renderCallback, DrawTextHint hint)
   at MindFusion.Diagramming.Wpf.ShapeNode.xeda13f64d938197c(DrawingContext x41347a961b838962, RenderOptions xdfde339da46db651)
   at MindFusion.Diagramming.Wpf.ShapeNode.xc79d59e9288101bd(DrawingContext x41347a961b838962, Rect xa6236fc5cd405c4e, Boolean x2f9dabff87b2168b, Brush xb45de92d01a0ec1f, Pen x9c79b5ad7b769b12, RenderOptions xdfde339da46db651)
   at MindFusion.Diagramming.Wpf.ShapeNode.Draw(DrawingContext graphics, RenderOptions options)
   at Components.ValueObject.QuestionNode.Draw(DrawingContext graphics, RenderOptions options) in C:\Source\QuestionNode.cs:line 51

Thanks
  
Back to top
 
IP Logged
 
tusharpateluk
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 3rd, 2008
Re: Error after LoadfromXML for Custom Shape node
Reply #1 - Oct 1st, 2008 at 12:58pm
Print Post  
While handling the exception on the Draw method, if I don't throw any exception then execution continues and Diagram is loaded.

But, I am still not sure, if it is a bug or I might be missing something.

Below is the Draw method.

public override void Draw(DrawingContext graphics, MindFusion.Diagramming.Wpf.RenderOptions options)
{
try
{
base.Draw(graphics, options);
}
catch (Exception)
{
}
}

Please help me, if you have faced similar problem
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Error after LoadfromXML for Custom Shape node
Reply #2 - Oct 1st, 2008 at 1:49pm
Print Post  
Could you also post the LoadFromXml override code here?
  
Back to top
 
IP Logged
 
tusharpateluk
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 3rd, 2008
Re: Error after LoadfromXML for Custom Shape node
Reply #3 - Oct 2nd, 2008 at 2:49pm
Print Post  
Below is the LoadfromXML method along with the SetCustomData method

protected override void LoadFromXml(XmlElement xmlElement, MindFusion.Diagramming.Wpf.XmlPersistContext context)
{
SetCustomData(xmlElement);
base.LoadFromXml(xmlElement, context);
}


private void SetCustomData(XmlElement doc)
{
question = new QuestionProperty();
question.StepNumber = doc.SelectSingleNode("Question/StepNumber").InnerText;
("Question/Explanation").InnerText;
question.Eval = doc.SelectSingleNode("Question/Eval").InnerText;

}
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Error after LoadfromXML for Custom Shape node
Reply #4 - Oct 2nd, 2008 at 3:02pm
Print Post  
Have you also overridden the OnLoad method by any chance?
  
Back to top
 
IP Logged
 
tusharpateluk
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 37
Joined: Sep 3rd, 2008
Re: Error after LoadfromXML for Custom Shape node
Reply #5 - Oct 2nd, 2008 at 3:45pm
Print Post  
No, I have not override OnLoad method. Do I need to ?

As per my understanding and debugging, After LoadfromXML, draw method is called and once all the nodes are drawn then OnLoad method get's called.

Please let me know if you have any suggestion.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Error after LoadfromXML for Custom Shape node
Reply #6 - Oct 3rd, 2008 at 10:26am
Print Post  
Could you email the QuestionNode code to support@mindfusion.eu? What value does the Text property have when the exception happens?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint