Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Loading a diagram is giving an Exception. (Read 1711 times)
padmavathi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Loading a diagram is giving an Exception.
Jul 6th, 2010 at 5:24am
Print Post  
Hi
I have created a Silverlight application into which I want to load a Diagram through xml file.
This is what my LoadDiagram logic:

private void btnLoadClick(object sender, RoutedEventArgs e)
       {            
    OpenFileDialog openFileDlg = new OpenFileDialog();
   bool? isOpenFileDlgShown = openFileDlg.ShowDialog();
       if (isOpenFileDlgShown == true)
               {
                   FileInfo file = openFileDlg.File;                   
                  
                   using (var stream = file.OpenRead())
                   {
                       diagram.LoadFromXml(stream);
                   }

               }
       }

But when I run this I am getting the following exception:

{System.NullReferenceException: Object reference not set to an instance of an object.
   at MindFusion.Diagramming.Silverlight.Diagram.LoadFromXml(XDocument document)
   at MindFusion.Diagramming.Silverlight.Diagram.LoadFromXml(Stream stream)
   at LoadDiagram.MainPage.btnLoadClick(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEve
ntArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)}

Here the xml file iam trying to load is an xml file created/saved from another silverlight applicaton.
The thing i don't understand here If I try this from the earlier application where i am saving, i could able to load.
But when i do this in another application, the above mentioned exception is coming.

What is missing here, can anyone help me out?

Thanks & Regards
Padma
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Loading a diagram is giving an Exception.
Reply #1 - Jul 6th, 2010 at 5:52am
Print Post  
Hi,

If you are using any custom node types, you should add them to all applications that are expected to load this file, and also call the RegisterItemClass method when the applications load. RegisterItemClass maps the element names from the diagram xml file to the node classes you are using.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
padmavathi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Re: Loading a diagram is giving an Exception.
Reply #2 - Jul 6th, 2010 at 12:32pm
Print Post  
Yes ..you are rigjht. I fotgot to call the RegisterItemClass.
Its working now.

Thanks & Regards
Padma
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint