Primary MDI WinForm break easily very often, why?? RRS feed

  • Question

  • Hi all of you,

    I've got a MDI with lots of controls: MenuStrip, ToolStrip, ContextMenuStrip,StatusStrip and ImageList.

    Twice or more a day when i wanna load this MDI in design-time I get a bunch of HTML stuff and I do not see the design surface and the controls.

    When it does happen, I close my application and open it again without problems.

    These are the lines affected:

            Me.ImageList1.Images.SetKeyName(4, "MC900434804.PNG")
            Me.ImageList1.Images.SetKeyName(5, "MC900434801.PNG")
            Me.ImageList1.Images.SetKeyName(6, "MC900431615.PNG")
            Me.ImageList1.Images.SetKeyName(7, "MC900434835.PNG")
            Me.ImageList1.Images.SetKeyName(8, "MC900431590.PNG")
            Me.ImageList1.Images.SetKeyName(9, "MC900431626.PNG")
            Me.ImageList1.Images.SetKeyName(10, "MP900387816.JPG")
            Me.ImageList1.Images.SetKeyName(11, "pintura_workpad.png")
            Me.ImageList1.Images.SetKeyName(12, "invoice-icon.png")

    For every previous assignment of every .PNG I get this error:

    El argumento especificado está fuera del intervalo de valores válidos.
    Nombre del parámetro: '4' no es un valor válido para 'index'.    C:\PUESTO\TALLERES\Taller\Formularios\frmTalleres.Designer.vb    1120    0    

    (specified argument out of index, parameter four is not a valid value for 'index')

    I am stuck, it does happen very often but not always...



    Friday, August 17, 2012 8:57 AM


  • Hi Enric,

    Thank you for posting on this forum.

    Please try to find a reproduce way that will help us to find the root cause.

    In addition, do you fill the ImageList in a multi-thread? 

    In my opinion, it seems that one thread try to execute your above code but another thread didn't finish the fill operation.

    If so, please try Lock: http://msdn.microsoft.com/en-us/library/3a86s51t.aspx 

    I hope this will be helpful.

    Best regards,

    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Mike Feng Thursday, September 6, 2012 3:14 AM
    Monday, August 20, 2012 7:39 AM