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

Invalid Operation Exception in XPTheme class


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 November 18, 2013 05:59 PM UTC

Hi Li,

Thanks for using Syncfusion Products.

We are unable to reproduce the issue at our end.

The problem is caused by a bug in the language compiler that was used to build the program.

When the invalid code runs, the JIT compiler detects the error, and then throws a System.InvalidProgramException.

In order to handle this exception, please do following steps:

1.      Provide valid code path that contains valid instructions.

2.      To determine whether your assembly contains invalid MSIL, run the PEverify tool over the program

3.      If the PEverify tool locates invalid MSIL, the language compiler that you used to build the application probably contains a bug.

If the PEverify tool does not locate invalid MSIL, the .NET Framework JIT compiler may contain a bug.

Karuppasamy C.

Live Chat Icon For mobile
Up arrow icon