Another InvalidOperationException

I’m using GoDiagram as a control to display some GoBasicNode’s depending on what the user selects/clicks in an other window. It works fine for a couple of “clicks” but then the GoDiagram control crashes and displays just a red cross. The exception text is as follows:’

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”>**************
Exception Text **************<?: prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”>System.InvalidOperationException:
Collection was modified; enumeration operation may not execute.<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at
System.Collections.Generic.List`1.Enumerator.MoveNextRare()<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at System.Collections.Generic.List`1.Enumerator.MoveNext()<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at Northwoods.Go.GoLayer.Paint(Graphics g,
GoView view, RectangleF clipRect)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at Northwoods.Go.GoView.PaintObjects(Boolean
doc, Boolean view, Graphics g, RectangleF clipRect)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at Northwoods.Go.GoView.PaintView(Graphics
g, RectangleF clipRect)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at
Northwoods.Go.GoView.onPaintCanvas(PaintEventArgs evt)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at
Northwoods.Go.GoView.OnPaint(PaintEventArgs evt)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at
System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16
layer)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at System.Windows.Forms.Control.WmPaint(Message&
m)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at
System.Windows.Forms.Control.WndProc(Message& m)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<o:p></o:p>

<p style=“margin: 0cm 0cm 0pt;” =“Msonormal”> at System.Windows.Forms.NativeWindow.Callback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


The behaviour is complete random, clicked objects that displayed the GoBasicNodes in the control correctly for one or several times may cause the control to crash some later time without any changes in the content.

I'm using .NET 4.0.

Any suggestions

BR,

Juri

It looks like you are modifying the GoDocument down inside Paint… you can’t do that. Go iterates the collections of layers and objects within layers to do the painting, and you can’t change a collection during an iteration of that collection.

Hi Jake,
************** Exception Text **************
System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
at Northwoods.Go.GoViewLicenseProvider.GoViewLicense.Dispose(GoView view)
at Northwoods.Go.GoView.onPaintCanvas(PaintEventArgs evt)
at Northwoods.Go.GoView.OnPaint(PaintEventArgs evt)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Any pointers?
regards,
Thunis

[QUOTE=thunis21]

I just remember, i upgraded from 4.1.0.4 to 4.2.0.4 on monday after i re-formatted my notebook solid state drive.

can it have to do with licensing?

Hi Jake,
************** Exception Text **************
System.ArgumentException: Parameter is not valid.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
at Northwoods.Go.GoViewLicenseProvider.GoViewLicense.Dispose(GoView view)
at Northwoods.Go.GoView.onPaintCanvas(PaintEventArgs evt)
at Northwoods.Go.GoView.OnPaint(PaintEventArgs evt)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Any pointers?
regards,
Thunis[/quote]

Looks like it. Check your licenses.licx and installed licenses.