Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic InvalidOperationException during diagram selection (Read 3397 times)
bradaisa
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Sep 9th, 2009
InvalidOperationException during diagram selection
Feb 19th, 2010 at 9:55pm
Print Post  
I have a tree structured diagram with a variety of nodes recursively emanating from a single root. Each node has a single link that connects it from its parent. When I have Ctrl-Click selected a number of nodes, then Ctrl-Click and drag the mouse to select more, I get an InvalidOperationException. Visual Studio does not indicate that any of my own code has been invoked in a nested way. I am not making any nodes or links in these selections.

Thanks for any tips.

Stack trace below:

+

$exception
{"Collection was modified; enumeration operation may not execute."}
System.Exception {System.InvalidOperationException}

>
mscorlib.dll!System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext() + 0x119 bytes

MindFusion.Diagramming.dll!MindFusion.Diagramming.Selection.x6e950a5680221e52() + 0xb1 bytes

MindFusion.Diagramming.dll!MindFusion.Diagramming.Selection.CompleteCreate(Syste
m.Drawing.PointF end = {X = 102.54689 Y = 62.0782051}) + 0x6c bytes

MindFusion.Diagramming.dll!MindFusion.Diagramming.InteractionState.Complete(Syst
em.Drawing.PointF point = {X = 102.54689 Y = 62.0782051}, MindFusion.Diagramming.Diagram diagram = {MindFusion.Diagramming.Diagram}) + 0x4fe bytes

MindFusion.Diagramming.WinForms.dll!MindFusion.Diagramming.WinForms.Behaviors.Be
haviorBase.OnMouseUp(System.Drawing.Point mousePosition = {X = 995 Y = 691}, System.Windows.Forms.MouseButtons mouseButton = Left) + 0x6b3 bytes

MindFusion.Diagramming.WinForms.dll!MindFusion.Diagramming.WinForms.DiagramView.
OnMouseUp(System.Windows.Forms.MouseEventArgs e = {X = 995 Y = 691 Button = Left}) + 0x36e bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks) + 0x28f bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x885 bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMess
age(ref System.Windows.Forms.Message m) + 0x10 bytes

System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndPro
c(ref System.Windows.Forms.Message m) + 0x31 bytes

System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(Sy
stem.IntPtr hWnd, int msg = 514, System.IntPtr wparam, System.IntPtr lparam) + 0x57 bytes

[Native to Managed Transition]

[Managed to Native Transition]

System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.Syste
m.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason = -1, int pvLoopData = 0) + 0x24e bytes

System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessa
geLoopInner(int reason = -1, System.Windows.Forms.ApplicationContext context = {Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.WinFormsA
ppContext}) + 0x177 bytes

System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessa
geLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes

System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.For
ms.ApplicationContext context) + 0x18 bytes

Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsForms
ApplicationBase.OnRun() + 0x81 bytes

Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsForms
ApplicationBase.DoApplicationModel() + 0xef bytes

Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsForms
ApplicationBase.Run(string[] commandLine) + 0x68 bytes

[Native to Managed Transition]

[Managed to Native Transition]

mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x3a bytes

Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.Hosti
ngProcess.HostProc.RunUsersAssembly() + 0x2b bytes

mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x66 bytes

mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionCon
text executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes

mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: InvalidOperationException during diagram selec
Reply #1 - Feb 20th, 2010 at 3:26pm
Print Post  
The selection collections are modified by the setters of some properties such as Visible, Locked and Selected. Are you by chance setting any of them in response to selection -related events?
  
Back to top
 
IP Logged
 
bradaisa
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Sep 9th, 2009
Re: InvalidOperationException during diagram selec
Reply #2 - Feb 20th, 2010 at 8:33pm
Print Post  
In one case, yes. However, before I do my own code, I get a List copy of the Selection (rather than doing my code in an iterator of Selection). Also, I notice that when I get the exception, the stack trace does not show any of my own code executing -- if my code was causing the issue, I would have expected to see my code on the stack trace. But I will try to reproduce this with breakpoints on all my possible code, to confirm for sure that it isn't executing.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: InvalidOperationException during diagram selec
Reply #3 - Feb 23rd, 2010 at 9:29am
Print Post  
You won't see your code in the stack trace in this case, because the problem happens at the next foreach iteration in the Selection class code if the iterated collection has been modified. The collection of selected items is modified when setting the Visible and Locked properties to false, or when setting Selected to any value. If you are doing that in response to Selected or Deselected events, try refactoring your code to do the required changes in response to the SelectionChanged event, which is raised just once after Ctrl+dragging the mouse.

I hope that helps,
Stoyan
« Last Edit: Feb 23rd, 2010 at 2:11pm by Stoyo »  
Back to top
 
IP Logged
 
bradaisa
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Sep 9th, 2009
Re: InvalidOperationException during diagram selec
Reply #4 - Mar 2nd, 2010 at 4:17pm
Print Post  
That worked, thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint