Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic AttachTo and NullReferenceException (Read 3716 times)
oOAnriOo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Oct 12th, 2009
AttachTo and NullReferenceException
Nov 26th, 2009 at 2:07pm
Print Post  
Im trying to attach 2 nodes derived from DrawingNode.

Both drawings exists on the diagram but for some reason I get a nullreference exception when calling the attachto function.

The code is too complex to show here, but is there something, other than creating 2 nodes on a diagram, I need to do before I can attach node 1 to node 2?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AttachTo and NullReferenceException
Reply #1 - Nov 26th, 2009 at 4:19pm
Print Post  
Could you post here the exception stack trace? What class does DrawingNode derive from?
  
Back to top
 
IP Logged
 
oOAnriOo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: Oct 12th, 2009
Re: AttachTo and NullReferenceException
Reply #2 - Dec 2nd, 2009 at 7:30am
Print Post  
Oh..  Sorry..
i meant DiagramNode, not DrawingNode.  My object is derived from MindFusion.Diagramming.DiagramNode and just a few parameters added.

Here is my stack trace :
Quote:
System.NullReferenceException was unhandled
  Message="Objektreferencen er ikke indstillet til en forekomst af et objekt."
  Source="MindFusion.Diagramming"
  StackTrace:
      ved MindFusion.Diagramming.DiagramNode.xf5780211a26cd3d0(DiagramItem xccb63ca5f63dc470)
      ved MindFusion.Diagramming.DiagramNode.AttachTo(DiagramNode node, AttachToNode attType)
      ved NeetsProjectEditor.Controls.Overview.ProjectOverview.CreateDrawing(ProjectDiagra
m diagram) i C:\Users\hlc\Documents\Visual Studio 2008\Projects\Project overview\Project overview\Project overview.cs:linje 152
      ved NeetsProjectEditor.Controls.Overview.ProjectOverview.ChangeViewMode() i C:\Users\hlc\Documents\Visual Studio 2008\Projects\Project overview\Project overview\Project overview.cs:linje 183
      ved NeetsProjectEditor.Controls.Overview.ProjectOverview.set_ViewMode(ViewModes value) i C:\Users\hlc\Documents\Visual Studio 2008\Projects\Project overview\Project overview\Project overview.cs:linje 54
      ved Project_overview.Form1.uiTrackBar1_ValueChanged(Object sender, EventArgs e) i C:\Users\hlc\Documents\Visual Studio 2008\Projects\Project overview\Project overview\Form1.cs:linje 58
      ved Janus.Windows.EditControls.UITrackBar.OnValueChanged(EventArgs e)
      ved Janus.Windows.EditControls.UITrackBar.set_Value(Int32 value)
      ved Janus.Windows.EditControls.UITrackBar.a(Int32 , Int32 )
      ved Janus.Windows.EditControls.UITrackBar.OnMouseMove(MouseEventArgs e)
      ved System.Windows.Forms.Control.WmMouseMove(Message& m)
      ved System.Windows.Forms.Control.WndProc(Message& m)
      ved System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
      ved System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
      ved System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
      ved System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
      ved System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNat
iveMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
      ved System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
      ved System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
      ved System.Windows.Forms.Application.Run(Form mainForm)
      ved Project_overview.Program.Main() i C:\Users\hlc\Documents\Visual Studio 2008\Projects\Project overview\Project overview\Program.cs:linje 18
      ved System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
      ved System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
      ved Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      ved System.Threading.ThreadHelper.ThreadStart_Context(Object state)
      ved System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      ved System.Threading.ThreadHelper.ThreadStart()
  InnerException:
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AttachTo and NullReferenceException
Reply #3 - Dec 2nd, 2009 at 9:16am
Print Post  
Hi,

The attach code tries to access the target's parent diagram at one point, so you might get this error if the target node hasn't been added to the diagram yet. Try calling AttachTo after diagram.Nodes.Add().

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


I love YaBB 1G - SP1!

Posts: 19
Joined: Oct 12th, 2009
Re: AttachTo and NullReferenceException
Reply #4 - Dec 2nd, 2009 at 9:43am
Print Post  
Damn..  How could I overlook such a simple mistake..

The case was just as you suggested. 

Thanks a lot.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AttachTo and NullReferenceException
Reply #5 - Dec 2nd, 2009 at 10:22am
Print Post  
It's more of our mistake, but it's easier to fix it on your side Wink
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint