Reseting the SfDiagram DataSourceSettings.DataSource causes System.NullReferenceException

Hi,

I am using the WPF NuGet version 17.4460.0.55 for the SfDiagram and it crashes when I reset the  DataSourceSettings.DataSource as sugested.
It happens when I add a new node by drawing a connector between two existing nodes, save the new node data into the database, reset the DataSource, query all my nodes back from the database and set it to the DataSource.  And every time it would crash when I reset the DataSource.  All of my constraints are defaults.  Below is how I reset my DataSource and exception detail.  Thank you in advance for you help!

Best regards,
Phong

DataSourceSettings.DataSource = null;
DataSourceSettings.DataSource = new ObservableCollection();


System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Syncfusion.SfDiagram.WPF
  StackTrace:
   at Syncfusion.UI.Xaml.Diagram.NodeWrapper.get_Constraints()
   at Syncfusion.UI.Xaml.Diagram.NodeWrapper.CanAutomaticPortCreation()
   at Syncfusion.UI.Xaml.Diagram.Controls.Adorner.EndThumbReleased(Point pageRelativePoint)
   at Syncfusion.UI.Xaml.Diagram.Controls.Adorner.EndThumbDragCompleted(Object sender, DiagramThumbDragEventArgs args)
   at Syncfusion.UI.Xaml.Diagram.Controls.DiagramThumbDragEventHandler.Invoke(Object sender, DiagramThumbDragEventArgs args)
   at Syncfusion.UI.Xaml.Diagram.Controls.DiagramThumb.OnDragComplete(DiagramThumbDragEventArgs args)
   at Syncfusion.UI.Xaml.Diagram.Controls.DiagramThumb.DiagramThumb_PointerReleased(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at MX2S.App.Main()


1 Reply

SV Sarathkumar V Syncfusion Team March 30, 2020 12:02 PM UTC

Hi Phong, 
Reported Issue: Null reference exception when we change the DataSource. 
From the given details and stack trace, we have prepared the simple sample for your requirement and we are unable to reproduce the reported issue. In the sample, we have created a layout in diagram using items in database. We have tried to add some nodes on to the layout using stencil drag and drop and then inserted the new items to the datasource. Then we have used button click event to save the datasource to the database, reset the datasource by querying all my nodes back from the database and set it to the DataSource. 
Please find the sample in below link. 
Regards, 
Sarath 


Loader.
Up arrow icon