in

The ORM Foundation

Get the facts!

Object reference not set to an instance of an object

Last post Mon, May 25 2009 6:28 by Matthew Curland. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • Sat, May 9 2009 16:02

    • halcwb
    • Top 75 Contributor
    • Joined on Fri, May 8 2009
    • Posts 7

    Object reference not set to an instance of an object

    I installed NORMA for V2008 (NORMA_VS2008_2009-03CTP.zip) with C# installed and also SQL server 2008 installed. I used the .bat file and the installation went smoothly. I started my first NORMA project and added objects using the fact editor. This worked. But when I tried to add objects using the toolbox I got the error "Object reference not set to an instance of an object", after which VS crashed. 

     Any help will be greatly appreciated.

     Regards -- Casper

  • Sun, May 10 2009 2:42 In reply to

    Re: Object reference not set to an instance of an object

    Casper,

    Sorry about the problem. As this does not appear to be a common problem, there may be something unusual on your machine that is triggering this issue.

    1. Is this happening for all objects, or one in particular (ValueType,ObjectifiedType,EntityType,Binary FactType, etc)
    2. Could you please get me a callstack with the crash information (a section near the bottom of the Documentation\Readme.htm file discusses error reporting). Try to get the information before trying the next step.
    3. Right click on the toolbox and choose 'Reset toolbox'. See if the problem clears up.

    It's hard to offer further suggestions on this issue without seeing a callstack. Any help you can give would be very much appreciated.

    Thanks,

    -Matt

  • Sun, May 10 2009 4:07 In reply to

    • halcwb
    • Top 75 Contributor
    • Joined on Fri, May 8 2009
    • Posts 7

    Re: Object reference not set to an instance of an object

     Matt,

     Thanks for the quick reply. To give you some further info:

    • I run Windows XP Prof (up to date) as a Virtual Box inside a Lenovo T61P laptop running Ubuntu Jaunty.
    • I have VS 2008 and SQL 2008 installed
    • I have installed NORMA using the bat file
    • Below I have printed the recorded stack trace
    • The error happens with every object I pick from the toolbox
    • I tried resetting the toolbox, but still the error appeared

    The callstack reads:

    System.NullReferenceException was unhandled
      Message="Object reference not set to an instance of an object."
      Source="ORMSolutions.ORMArchitect.Core.VS2008"
      StackTrace:
           at ORMSolutions.ORMArchitect.Core.ObjectModel.FactType.<GetForcedHierarchyContextElements>d__6b.MoveNext()
           at ORMSolutions.ORMArchitect.Core.Shell.ORMContextWindow.GetRelatedContextableElements(IHierarchyContextEnabled element, Int32 generations)
           at ORMSolutions.ORMArchitect.Core.Shell.ORMContextWindow.PlaceObject(IHierarchyContextEnabled element)
           at ORMSolutions.ORMArchitect.Core.Shell.ORMContextWindow.DrawDiagram(Boolean refresh, ModelElement element, IHierarchyContextEnabled hierarchyElement)
           at ORMSolutions.ORMArchitect.Core.Shell.ORMContextWindow.DrawDiagram(Boolean refresh)
           at ORMSolutions.ORMArchitect.Core.Shell.ORMContextWindow.DrawDiagram()
           at ORMSolutions.ORMArchitect.Core.Shell.ORMContextWindow.OnORMSelectionContainerChanged()
           at ORMSolutions.ORMArchitect.Core.Shell.ORMToolWindow.ActivatorSelectionContainerChanged(ToolWindowActivationHelper`3 activator)
           at ORMSolutions.ORMArchitect.Core.Shell.ORMToolWindow.ORMSolutions.ORMArchitect.Framework.Shell.INotifyToolWindowActivation<ORMSolutions.ORMArchitect.Core.Shell.ORMDesignerDocData,Microsoft.VisualStudio.Modeling.Shell.DiagramDocView,ORMSolutions.ORMArchitect.Core.Shell.IORMSelectionContainer>.ActivatorSelectionContainerChanged(ToolWindowActivationHelper`3 activator)
           at ORMSolutions.ORMArchitect.Framework.Shell.ToolWindowActivationHelper`3.IntraContainerSelectionChanged(Object sender, EventArgs e)
           at System.EventHandler.Invoke(Object sender, EventArgs e)
           at Microsoft.VisualStudio.Modeling.Shell.ModelingWindowPane.OnSelectionChanged(EventArgs e)
           at Microsoft.VisualStudio.Modeling.Shell.DiagramDocView.OnSelectionChanged(EventArgs e)
           at ORMSolutions.ORMArchitect.Framework.Shell.MultiDiagramDocView.OnSelectionChanged(EventArgs e)
           at ORMSolutions.ORMArchitect.Core.Shell.ORMDesignerDocView.OnSelectionChanged(EventArgs e)
           at Microsoft.VisualStudio.Modeling.Shell.ModelingWindowPane.SetSelectedComponents(ICollection components)
           at Microsoft.VisualStudio.Modeling.Shell.VSDiagramView.OnShapeSelectionChanged(Object sender, EventArgs e)
           at Microsoft.VisualStudio.Modeling.Diagrams.SelectedShapesCollection.OnShapeSelectionChanged(EventArgs e)
           at Microsoft.VisualStudio.Modeling.Diagrams.SelectedShapesCollection.InternalSetSelection(DiagramItemCollection proposedItemsToAdd, DiagramItemCollection proposedItemsToRemove, DiagramItem proposedPrimaryItem, Boolean clearSelection)
           at Microsoft.VisualStudio.Modeling.Diagrams.SelectedShapesCollection.Set(DiagramItemCollection diagramItems)
           at Microsoft.VisualStudio.Modeling.Diagrams.SelectedShapesCollection.Set(DiagramItem diagramItem)
           at Microsoft.VisualStudio.Modeling.Diagrams.SelectAction.ReplaceSelection(SelectedShapesCollection selection, DiagramItem selectableItem, DiagramItem focusableItem, Boolean preserveSelectionIfItemAlreadySelected, DiagramClientView view)
           at Microsoft.VisualStudio.Modeling.Diagrams.SelectAction.Select(DiagramMouseEventArgs mouseArgs)
           at Microsoft.VisualStudio.Modeling.Diagrams.SelectAction.OnMouseDown(DiagramMouseEventArgs e)
           at ORMSolutions.ORMArchitect.Core.ShapeModel.RoleDragPendingAction.OnMouseDown(DiagramMouseEventArgs e)
           at Microsoft.VisualStudio.Modeling.Diagrams.MouseAction.InvokeMouseActionEventMethods(MouseActionEvent mouseActionEvent, DiagramEventArgs diagramArgs)
           at Microsoft.VisualStudio.Modeling.Diagrams.MouseAction.FlushInternalEventQueue()
           at Microsoft.VisualStudio.Modeling.Diagrams.MouseAction.MouseDown(DiagramMouseEventArgs mouseArgs)
           at Microsoft.VisualStudio.Modeling.Diagrams.DiagramClientView.OnMouseDown(MouseEventArgs e)
           at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at Microsoft.VisualStudio.Modeling.Diagrams.DiagramClientView.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)
      InnerException: 

  • Sun, May 10 2009 12:19 In reply to

    Re: Object reference not set to an instance of an object

    Ouch. I'm surprised this hasn't been reported before (it's been there since November), thanks for posting.

    When the context window is visible, selecting any FactType with a missing role player will crash.

    However, you shouldn't have any problem with non-FactType elements on the toolbox.

    As is common with a 'null reference exception', the fix is trivial (check for null).

    For now, just close the Context Window.

    -Matt

  • Sun, May 10 2009 15:06 In reply to

    • halcwb
    • Top 75 Contributor
    • Joined on Fri, May 8 2009
    • Posts 7

    Re: Object reference not set to an instance of an object

    Glad to be of help. I have seen the infamous null reference error all too often myself (being a modest amateur programmer). 

    Thanks for your suggestion. I tried adding an object with the context window closed, and indeed this worked.

    I am still a bit curious how this error crashes VS2008, is not the NORMA code managed?

    Regards -- Casper 

     

  • Mon, May 11 2009 10:20 In reply to

    Re: Object reference not set to an instance of an object

    Casper,

    Managed code doesn't make NORMA immune from crashing the host in all cases. Generally, an error that occurs during a document change will be caught automatically and directly reported, unless there is a stack problem, in which case the IDE is done. However, exceptions in tool window implementations and paint routines can take down the environment.

    Tool windows update in response to:

    1. 'Events' resulting from direct changes to the selected model, or an undo/redo operation. We have a wrapper framework in place for any events we register (this doesn't catch framework-registered events, however) that stops a rogue tool window from bringing down the full system with an unexpected exception.
    2. Direct requests from Visual Studio. These are generally apply to window activation/deactivation, command routing (executing menu and toolbar commands), and selection changes. Responses to these changes are made during through interop to the underlying VS interfaces. There is nothing built-in to naturally catch unexpected exceptions. The crash in question happens in response to a selection change.

    -Matt

    PS Although C#/.NET is a much more productive environment than C++, I do miss the ability to do if (this == null) inside an instance method. This C++ programming paradigm can be leveraged to provide default values on non-virtual methods for safe property retrieval with constantly checking for null in the calling code, adding one more layer of robustness to C++ objects. The class information stored with the instance in a managed system precludes a null this in managed languages.

  • Thu, May 21 2009 15:24 In reply to

    • vancottt
    • Top 500 Contributor
    • Joined on Thu, May 21 2009
    • Posts 1

    Re: Object reference not set to an instance of an object

     Hey Matt, thanks for posting up an easy solution to this. I was able to get the tool running for this project I'm working on. Good stuff.

     

    -TJ

  • Mon, May 25 2009 6:28 In reply to

    Re: Object reference not set to an instance of an object

    This problem was fixed in changeset 1385 and the fix is included in the May 2009 CTP.

    -Matt

Page 1 of 1 (8 items)
© 2008-2024 ------- Terms of Service