Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Unhandled Exception is Coming (Read 3478 times)
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Unhandled Exception is Coming
Aug 6th, 2010 at 10:12am
Print Post  
Hi,

We are getting unhandled exception in our application when we delete some nodes and in the same time trying to select some other nodes.

Code
Select All
Unhandled Exception in Application
--------------------------------------
DateTime: 8/6/2010 2:16:55 PM
Exception: Object reference not set to an instance of an object.
Stack Trace:    at MindFusion.Diagramming.Wpf.InteractionState.IsAllowed(Point point)
   at MindFusion.Diagramming.Wpf.Behaviors.BehaviorBase.OnMouseUp(Point mousePosition, MouseButton mouseButton)
   at MindFusion.Diagramming.Wpf.Diagram.x355258a28dc3da25(MouseButtonEventArgs xfbf34718e704c6bc, Point xb30c565aa19aece6)
   at MindFusion.Diagramming.Wpf.Diagram.OnPreviewMouseUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnPreviewMouseUpThunk(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.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, Int32 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, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
Exception Source: MindFusion.Diagramming.Wpf
InnerException:
-------------------------------------- 



Scenario is like this,
1. We have opened two instances of our application.
2.  Application is synchronized through the event, change in one instance reflects in another instance.
3. We have Tile both the window and select some node in first instance.
4. Delete selected node of first instance and at the same time try to select those nodes in second instance.

After step 4, we are getting above mentioned exception.

Please let us know your suggestion as soon as possible. It is a critical issue for our application.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Unhandled Exception is Coming
Reply #1 - Aug 6th, 2010 at 10:50am
Print Post  
Hi,

It looks as if some diagram item disappears while it is being modified. If your synchronization code deletes items, you might check if (diagram.Interaction != null) before deleting, and if so, call diagram.CancelDrag().

Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Unhandled Exception is Coming
Reply #2 - Aug 13th, 2010 at 6:22am
Print Post  
Hi,

1. We have tried your suggested solution, it is working 4 out of 5 times but now if we try to select those nodes which are deleting from first instance, due to CancelDrag() we are not able to select them. How we can allow selection of nodes but no crashing?

2. Here is one another issue,

Scenario is same as above, now we are trying to delete some nodes from 1st instance and at the same time we are trying to copy-paste those nodes (which are yet to be deleted) from 2nd instance. During this operation we are getting same exception which we have mentioned earlier, any suggestion for this?

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Unhandled Exception is Coming
Reply #3 - Aug 13th, 2010 at 7:02am
Print Post  
Hi,

1. Then you should not call CancelDrag if (Interaction.CurrentItem is Selection && Interaction.Action == Action.Create)

2. Are you targeting 4-armed users or what. I suppose you will get all kinds of exceptions if your synchronization code runs from a second thread, is that so? In such case, try using Dispatcher.Invoke to run any code that modifies the diagram from the UI thread.

Regards,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Unhandled Exception is Coming
Reply #4 - Aug 14th, 2010 at 11:58am
Print Post  
Hi Stoyan,

Thanks for your prompt reply :

I just describing my issues again:

We have application where multiple instances are always synchronized with event mechanism. now we are facing following 2 issues:

1. User1 is deleting some nodess, the User 2 will get events and nodes will start getting deleted and if at this time user2 trying to select any device other than the deleted by user 1,he is getting unhandelled exception. Log is attached in previous post.
So after your suggestion to add cancelDrag(), now the crashing is not coming but the user 2 not able to select the node while some node are getting deleted.

So deletion is also done from the UI thread and selection is also is on the same thread.

We want user to be able to select nodes while other nodes are getting deleted through events.

2. User 1 has deleted all the object and User 2 was not aware of deletion he copied one object before deletion started in his instance and is trying to paste that object to create its copies, then the application is getting crashed and log file is same as in the above issue.

So we tried the same cancelDrag() approach here, So we are not getting the that much frequently, but its reproducible 2 out of 10 trial.

This functionality is very critical to us.

It will be great if you help in resolving this issue.


Thanks and Regards
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Unhandled Exception is Coming
Reply #5 - Aug 16th, 2010 at 6:00am
Print Post  
Hi Anshul,

1. Still as #1 from the post above. Call CancelDrag when diagram.Interaction != null, but not if it's creating a selection rectangle. Perhaps a better approach is to queue the sync operations for execution until after the interaction ends, e.g. in response to Created, Modified or Cancelled events.

2. I imagine this would happen if you are using the CopySelection and PasteSelection methods, which keep references to the original objects. Use CopyToClipboard and PasteFromClipboard instead.

Regards,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Unhandled Exception is Coming
Reply #6 - Aug 17th, 2010 at 7:00am
Print Post  
Hi Stoayn,

Thanks for your prompt reply.

Could you please provide a small code for your reply:
1. Still as #1 from the post above. Call CancelDrag when diagram.Interaction != null, but not if it's creating a selection rectangle. Perhaps a better approach is to queue the sync operations for execution until after the interaction ends, e.g. in response to Created, Modified or Cancelled events.

How we can identify that selection rectangle is being created and also would like to know how we sync oepration using Created, modified and cancelled events.

Thanks and Regards
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Unhandled Exception is Coming
Reply #7 - Aug 17th, 2010 at 9:44am
Print Post  
Hi Anshul,

This checks if there's a selection rectangle being drawn:

Code
Select All
if (diagram.Interaction != null &&
	diagram.Interaction.CurrentItem == diagram.Selection &&
	diagram.Interaction.Action == Action.Create)
{
	// drawing selection rect
} 



If your current synchronization looks like this:

Code
Select All
void OnSyncEvent(SyncEvent e)
{
	Process(e);
} 



you can queue the operations for executing them after interaction completes as shown below

Code
Select All
Queue<SyncEvent> commandQueue = new ...;
void OnSyncEvent(SyncEvent e)
{
	if (diagram.Interaction == null)
		Process(e);
	else
		commandQueue.Enqueue(e);
}

void OnDiagramMouseUp(...)
{
	if (diagram.Interaction == null)
	{
		while (commandQueue.Count > 0)
			Process(commandQueue.Dequeue());
	}
} 



I think handling MouseUp should be enough, instead of handling all Created, Modified and Cancelled event.

Regards,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint