We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Invalid Operation Exception in XPTheme class

Hi,

My application used the SyncFusion GridControl. Occasionally I met some crashes exposed from the Grid. The callstack of the exception looks like below:

Exception type: System.InvalidOperationException
Message: Collection was modified; enumeration operation may not execute.
InnerException: <none>
StackTrace (generated):
    SP       IP       Function
    0045ED60 73767F9A mscorlib_ni!System.Collections.Hashtable+HashtableEnumerator.MoveNext()+0x72815a
    0045ED70 15DF5C44 Syncfusion_Shared_Base!Syncfusion.Windows.Forms.XPThemes.ResetThemeHandles()+0x74
    0045ED9C 15DF5BB1 Syncfusion_Shared_Base!Syncfusion.Windows.Forms.XPThemes.ApplicationExit(System.Object, System.EventArgs)+0x31
    0045EDA8 71C546DF System_Windows_Forms_ni!System.Windows.Forms.Application.RaiseExit()+0x6f
    0045EDB4 71C764D3 System_Windows_Forms_ni!System.Windows.Forms.Application+ThreadContext.Dispose(Boolean)+0x1b3
    0045EE1C 71C989F6 System_Windows_Forms_ni!System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)+0x276
    0045EE74 71C98741 System_Windows_Forms_ni!System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)+0x61
    0045EEA4 71C55911 System_Windows_Forms_ni!System.Windows.Forms.Application.Run(System.Windows.Forms.Form)+0x31

I'm not sure whether this issue was reported before. Can you give me any clue from the above callstack?

Please do not ask me for the code snippet. Thanks.

1 Reply

KC Karuppasamy C Syncfusion Team October 25, 2013 03:35 AM UTC

Hi Li,

Thank you for your interest in Syncfusion Products.

I have analyzed your posted issue in our side.

InvalidOperationException is thrown   because of following reasons,

1. Method call is invalid for the object's current state.

2. Modifications of collections’ objects after the enumerator are created.

3. Resource set is closed before the method call is made.

The important part of the InvalidOperationException means is the Message property. The message says "Collection was modified" and that the enumeration won't work.

This is because you are changing the elements in the collection while looping over it.

To resolve that, please follow the steps,

1. Set the valid enumerator’s state

2. Add references to all the objects.

3. Iterating over the temporary collection.

 

Regards

Karuppasamy C.

 


Loader.
Live Chat Icon For mobile
Up arrow icon