none
null pointer exception

    Question

  • Hello,
    I am trying to dynamically remove a node from my graph and redraw it. Below is the code showing how I am deleting the node (and attached edges) and the stack trace of the exception. Could you please look into this issue and let me know if I am doing something wrong or if there is a bug.
    Regards,
    Mike Castillo
    Code to delete node:
    -----------------------
    if (gViewer.SelectedObject != null)
                {
                    Node node = (Node)gViewer.SelectedObject;
                    foreach (Edge es in node.OutEdges)
                    {
                        gViewer.Graph.Edges.Remove(es);
                    }
                    foreach (Edge es in node.InEdges)
                    {
                        gViewer.Graph.Edges.Remove(es);
                    }
                    Graph g = gViewer.Graph;
                    g.NodeMap.Remove(node.Id);
                    gViewer.Graph = g;


    Exception: "Object reference not set to an instance of an object."
    --------------
       at Microsoft.Glee.Drawing.CreateLayoutGraph.CreateGleeNode(GleeGraph g, Node n)
       at Microsoft.Glee.Drawing.CreateLayoutGraph.Create(Graph graph, GleeGraph parent)
       at Microsoft.Glee.Drawing.CreateLayoutGraph.Create(Graph graph)
       at Microsoft.Glee.Drawing.Graph.get_GleeGraph()
       at Microsoft.Glee.GraphViewerGdi.GViewer.LayoutAndCreateDGraph()
       at Microsoft.Glee.GraphViewerGdi.GViewer.set_Graph(Graph value)
       at com.goldsys.gswl.DecisionMatrixBuilder.GraphViewer.DeleteStep_OnClick(Object sender, EventArgs e) in C:\Documents and Settings\castillo\My Documents\Visual Studio 2005\Projects\framework\ApplicationModelBuilder\GraphViewer.cs:line 154
       at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
       at System.Windows.Forms.MenuItem.MenuItemData.Execute()
       at System.Windows.Forms.Command.Invoke()
       at System.Windows.Forms.Command.DispatchID(Int32 id)
       at System.Windows.Forms.Control.WmCommand(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.UserControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at com.goldsys.gswl.DecisionMatrixBuilder.Program.Main() in C:\Documents and Settings\castillo\My Documents\Visual Studio 2005\Projects\framework\ApplicationModelBuilder\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
    Saturday, April 04, 2009 11:26 PM

Answers

  • Hi Mike,
    I think you can call gViewer.RemoveNode(IViewerNode node, bool registerForUnde) as in the Editing sample.
    Thanks,
    Lev
    Lev Nachmanson
    Monday, April 06, 2009 4:41 PM