I've been trying to find out more about this problem and I'm not having much luck. I keep reading that applications should not have this error come up and although that's all fine and dandy, it doesn't tell me what can cause this error to show up.
I know this question is very broad as I'm sure there can be multiple causes for this error so I'll try to narrow it down a bit.
I'm working in VS2003 developing an application that uses C++.NET
The application uses mostly unmanaged code and little managed code (due to heavy interference by the garbage collector). So I'd rate it 95% unmanaged, 5% managed
I've read somewhere that unstable/buggy/incorrect unmanaged code can mess up parts of the CLR memory rendering it corrupt and throwing this error.
Since 95% of the application is unmanaged, I'm not sure where to start looking. Maybe the few classes that interact between managed and unmanaged? What about marshalling data from managed to unmanaged? Can a bad null pointer cause this failure? What other problems can cause this? Array Index out of bounds? What about a Null Object?
Any information/paper/article that can give a nice list of possible causes for the System.ExecutionEngine failure would be appreciated!
Based on answers this exception can be caused in multiple scenarios, mentioning them here in the question for better visibility.
List of possible causes/scenarios:
- Argument mismatch between C++ and C#
- While using reflection
- WCF service tries to return an IList or IEnumerable here here
- Using Profiling tools
- using the std instruction in assembler
- calling ::FreeLibrary() multiple times
- .NET Clipboard calls
- using the Unity Framework
- Using the wrong marshaling
- Using
INotifyPropertyChanged
Possible workarounds/solutions:
See Question&Answers more detail:os