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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Invalid Operation Exception in XPTheme class

Thread ID:





114002 Oct 22,2013 10:07 AM UTC Oct 25,2013 03:35 AM UTC WPF 1
Tags: GridControl
Li Yong
Asked On October 22, 2013 10:07 AM UTC


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.

Karuppasamy C [Syncfusion]
Replied On 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.



Karuppasamy C.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon