locked
Help with an error message RRS feed

  • Question

  • When I install my app on the machine I developed it on, I do not get an error. I am trying to include the dlls in the build, but the previous was set to download them. This install went fine on my second machine, but I get an error message:

    System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
       at System.Collections.Generic.List`1.Enumerator.MoveNext()
       at Microsoft.VisualBasic.PowerPacks.ShapeCollection.Dispose(Boolean disposing)
       at Microsoft.VisualBasic.PowerPacks.ShapeContainer.Dispose(Boolean disposing)
       at System.ComponentModel.Component.Dispose()
       at System.Windows.Forms.Control.Dispose(Boolean disposing)
       at System.Windows.Forms.Form.Dispose(Boolean disposing)
       at WindowsApplication1.Form1.Dispose(Boolean disposing)
       at System.ComponentModel.Component.Dispose()
       at System.Windows.Forms.Form.WmClose(Message& m)
       at System.Windows.Forms.Form.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)

    Could someone walk me through this message?
    I have been using the GetChanges() command with my Updates.  I was recently informed to remove them.  I have a few projects going and coded them with Options Strict Off.  as I turned it On,  it flagged this.  Could this be where the error is?  The app I am working on here still has some options strict on forms.

    • Edited by -tE Saturday, January 10, 2015 11:49 PM
    Saturday, January 10, 2015 11:43 PM

Answers

  • Will I need to recreate it when I load the form?  If I simply open the app and then close it,  I get this message.  Even if I haven't opened Form1 which is where I guess the trouble is.  For if I close that Form I get the error also.  I don't get it on the other forms.

    Is there a properties to set for these shapes that might be causing it?

    Also,  I am coding it .NET4 not 4.5.  Is there a possible error from this?

    I don't know what you are intending to recreate.

    VB .Net creates default instances of the forms in the application whether or not you actually show them.

    You could experiment with the shapes to see if it affects the problem but there is nothing to indicate that theproblem is with the shapes themselves.   By far the best solution is to replace whatever you are doing with those shapes with drawing - it will be faster, more flexible, does not require additional references and is not prone to this problem.

    There is nothing to indicate that the problem would disappear in a later version of the framework.

    • Marked as answer by -tE Sunday, January 11, 2015 5:27 AM
    Sunday, January 11, 2015 3:52 AM

All replies

  • tE,

    That's a bit confusing.

    Is the exception thrown when running your program or do you mean there's an error with the installer when running it?


    Still lost in code, just at a little higher level.

    :-)

    Saturday, January 10, 2015 11:49 PM
  • When running the app.
    Sunday, January 11, 2015 12:29 AM
  • When running the app.

    That's not much to go on, but the first line is telling what's causing it: The collection was modified while it's trying to be enumerated (for example, trying to remove an item from the collection going forward).

    That said though, it should be the case with all of them, not just one of them.

    Are all of the reference .dll files installed? I see one for PowerPacks - that's an obvious one to look for. I would think it would throw a different exception but start there anyway.

    Still lost in code, just at a little higher level.

    :-)

    Sunday, January 11, 2015 12:37 AM
  • Could someone walk me through this message?

    When form1 is closing the ShapeContainer needs to be disposed.  This is a container control that is created for you in order to contain any shapes that you have used on the form.  It will therefore have a collection of shapes.  See:
    http://msdn.microsoft.com/en-AU/library/microsoft.visualbasic.powerpacks.shapecontainer.aspx
    http://msdn.microsoft.com/en-AU/library/system.windows.forms.control.controlcollection.aspx

    It appears that when the code iterates over the Controls collection of the ShapeContainer to dispose of the shapes it is generating an error by modifying that collection. That is not code that you have written, so it is likely due to some incompatibility, which in turn is likely due to this: " I am trying to include the dlls in the build".   It is always safest to allow the user to download their own updates rather than delivering them packaged within an application.

    Sunday, January 11, 2015 1:17 AM
  • Will I need to recreate it when I load the form?  If I simply open the app and then close it,  I get this message.  Even if I haven't opened Form1 which is where I guess the trouble is.  For if I close that Form I get the error also.  I don't get it on the other forms.

    Is there a properties to set for these shapes that might be causing it?

    Also,  I am coding it .NET4 not 4.5.  Is there a possible error from this?

    • Edited by -tE Sunday, January 11, 2015 2:36 AM
    Sunday, January 11, 2015 2:04 AM
  • Will I need to recreate it when I load the form?  If I simply open the app and then close it,  I get this message.  Even if I haven't opened Form1 which is where I guess the trouble is.  For if I close that Form I get the error also.  I don't get it on the other forms.

    Is there a properties to set for these shapes that might be causing it?

    Also,  I am coding it .NET4 not 4.5.  Is there a possible error from this?

    I don't know what you are intending to recreate.

    VB .Net creates default instances of the forms in the application whether or not you actually show them.

    You could experiment with the shapes to see if it affects the problem but there is nothing to indicate that theproblem is with the shapes themselves.   By far the best solution is to replace whatever you are doing with those shapes with drawing - it will be faster, more flexible, does not require additional references and is not prone to this problem.

    There is nothing to indicate that the problem would disappear in a later version of the framework.

    • Marked as answer by -tE Sunday, January 11, 2015 5:27 AM
    Sunday, January 11, 2015 3:52 AM
  • I can probably do that.  Just use the PictureBox and draw lines?  I was concerned with which image would be on top. Some of the lines are under other PictureBoxes. 

    P.S.  Just did and it works slick.  I haven't compiled and installed it on the other machine,  but feel it should work.  When I deleted the PowerPack Lines the ShapeContainer.Dispose() I had added errored so I was able to tell which lines they were.  Thanks!!

    • Edited by -tE Sunday, January 11, 2015 5:27 AM
    Sunday, January 11, 2015 4:45 AM
  • Just use the PictureBox and draw lines?  I was concerned with which image would be on top. Some of the lines are under other PictureBoxes. 
    Just draw lines on the form.  Don't use picture boxes for drawing. Controls will be on top of whatever you draw.
    Sunday, January 11, 2015 4:55 AM
  • I haven't done that yet.

    I am a little concerned about my other app.  I am using  RectanleShape PowerPack shapes.  Not too many, but lots of code for the user can change the fill,  color,  background, etc.  Is this going to be an issue as well?  I haven't done too much with the graphics yet.  I have been introduced to using the picturebox to draw a controllable "knob" which is a circle with a line inside.  I have code snips to do so,  but to redo the structure of these background rectangleshapes would be a bit of work.

    Sunday, January 11, 2015 6:32 AM
  • I am a little concerned about my other app.  I am using  RectanleShape PowerPack shapes.  Not too many, but lots of code for the user can change the fill,  color,  background, etc.  Is this going to be an issue as well?

    You will have to try it to find out.

    The existing code is probably about asking the user to indicate color, line width etc. That won't change.  Don't use pictureboxes for drawing - they are only suitable for displaying an image.

    Sunday, January 11, 2015 6:50 AM
  • I just installed the second app on my second machine.  Ran great,  but on closing I got the same error.  I don't get what it's missing.  It doesn't do this on the machine I am debugging.  I was thinking that the appropriate PowerPack isn't there.  I was able to manipulate everything correctly, color, fill, etc. Any ides?  There has to be a simple fix other than redoing the RectangleShape itself.
    Sunday, January 11, 2015 8:04 PM
  • There has to be a simple fix other than redoing the RectangleShape itself.

    If the fix was simple it would already be implemented.   If you want to stick with the ShapeContainer you can have a look at the solutions discussed here:

    http://channel9.msdn.com/Forums/TechOff/520076-VB-2010-Error-PowerPacks-Line-Shape-Dispose

    Sunday, January 11, 2015 8:31 PM
  • I have implemented this and not really successful. Plus it doesn't appear to be quite correct. It calls the Dispose() twice. So I altered it and just call it once. In debug it works that way and not the other, but I still get the error.  I would like to solve this just for knowledge.  Any ideas?  I have dispose of each shape I believe.  When I removed them from my other app everything is clean.  I may end up trying a drawing anyway,  but would like to know how to do this.  The fillgradient feature is the main reason.  Drawing that would take awhile to code.  I have a user interface which allows changing the borders, fill, etc. and don't really want to have to try coding all of it.



    • Edited by -tE Monday, January 12, 2015 3:57 AM
    Monday, January 12, 2015 3:39 AM