This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
After upgrading our project to Diagrams 3, we're now getting a NullReferenceException when deleting a node. This appears to be occurring within an event handler inside of DiagramSurface. The stack trace is below. Given that the method in question is obfuscated, it's difficult to tell where to even approach fixing this on our end. I have verified that our Model class and the node remover are successfully removing the element from the model - so the exception is happening sometime after the call to Diagram.NodeRemover().RemoveNodes(Diagram, nodes); within Delete_Executed. I thought maybe this was due to the UndoManager, so I set IsUndoManagerEnabled to false on the diagram surface, but it still occurs. -Reed ---- Stack Trace ----- StackTrace " at Mindscape.WpfDiagramming.DiagramSurface.#XA(Object sender, ExecutedRoutedEventArgs e)\r\n at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)\r\n at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)\r\n at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)\r\n at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)\r\n at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)\r\n at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)\r\n at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)\r\n at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)\r\n at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)\r\n at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)\r\n at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)\r\n at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)\r\n at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)\r\n at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)\r\n at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)\r\n at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)\r\n at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)\r\n at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)\r\n at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)\r\n at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)\r\n at System.Windows.Input.InputManager.ProcessStagingArea()\r\n at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)\r\n at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)\r\n at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)\r\n at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)\r\n at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)\r\n at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)\r\n at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)\r\n at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)\r\n at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)\r\n at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)\r\n at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)\r\n at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)\r\n at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)\r\n at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)\r\n at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)\r\n at System.Windows.Threading.Dispatcher.Run()\r\n at System.Windows.Application.RunDispatcher(Object ignore)\r\n at System.Windows.Application.RunInternal(Window window)\r\n at |
|
|
We figured this out - Our Model was deriving from DiagramModelBase The DiagramModelBase I would consider this a bug in the base class implementation. We easily can work around it by providing our own override of that property, and returning an empty collection. -Reed |
|
|
I too have just run into this "null exception" when trying to delete nodes. Edit: "Object reference not set to an instance of an object." is the exception. try/catch doesn't let me get any further detail. No inner exception. I don't have the source code yet so I can't dig deeper. I am on the 20130115 nightly build. |
|
|
ctludlow - Make sure that IDiagramModel.CustomItems doesn't return null (which is the default in the base class) - that was what did it to us. By overriding that property, we were able to fix/workaround the issue. -Reed |
|
|
Thanks Reed! |
|
|
Well I am stuck on this because I don't have the source code yet (We all know how the purchasing department process can drag on) and the CustomItems property doesn't have a setter. I'm new to Mindscape controls and don't see how CustomItems is ever initialized. I'm thinking I'll have to wait until Jason has time to look at this? |
|
|
ctludlow - You just need to override the property in your IDiagramModel class:
That will cause it to work correctly and stop crashing. No source required. -Reed |
|
|
Ah, you rolled your own DiagramModel class. I was using the default implementation. I'll do this now. Thanks for the heads up. |
|
|
You can just subclass the default implementation, and override that property. (You don't need to roll your own from scratch - just derive from the default base model class) |
|
|
Yes, that is what I really meant. I assumed you had "rolled your own" because you guys were putting in custom code. I'm still getting my feet wet with Mindscape so I haven't gotten that far yet =) |
|
|
Ok, I am not experiencing the same issue as you. I had a face-palm moment when I realized my silly mistake by not checking the NodeRemover as being null. I can remove nodes now, for the moment at least. Hey Reed, since you seem to be replying frequently, do you know where I can get the Diagram documentation? I see many mentions of documentation for the UndoManager, the Diagram surface, etc but I can't find it for the life of me. My trial download included a .chm, but that is pretty useless except for basic examples and raw class references. It seems like there is a more robust set of docs floating around that I can't locate. |
|
|
The chm is the only docs, as far as I know. It's also online at: http://www.mindscapehq.com/Help/wpf-diagrams/Index.aspx |
|
|
Hello The null reference exception was resolved last week. The diagram now accepts a null collection of custom items. Updating to the latest nightly build will resolve this issue. The chm and online docs are the only sources of documentation for WPF Diagrams. Let me know if there is anything you need me to clarify or help with. Jason Fauchelle |
|