What causes 'System.ExecutionEngineException' ?

  • Thread starter Thread starter Tim Mulholland
  • Start date Start date
T

Tim Mulholland

I have an application that uses an external C(?) Dll and it seems like
after I make a specific call to that dll the application will crash at a
random call to the dll in the future. It sometimes crashes the next call
after said call, while sometimes it doesn't crash for 5 minutes; but it
always crashes.

As long as I don't call tira_get_captured_data it doesn't crash so I am
assuming that is the cause. I get a System.ExecutionEngineException error
in System.Windows.Forms.dll or mscorlib.dll and it does not give me a line
number so I am stuck. The call that seems to be the beginning of the end is
[DllImport("Tira2.dll")] public static extern int tira_get_captured_data(ref
IntPtr data, ref int size); I had to make a few conversions, its original
def is
extern "C" __stdcall int tira_get_captured_data ( const unsigned char**
data, int* size )

Is something wrong with the conversion I made?


Thanks in advance
 
Hello Tim,

Thanks for your post. As I understand, the problem you are facing is that
it throws System.ExecutionEngineException. Please correct me if there is
any misunderstanding. I'd like to share the following information with you:

1. MSDN documentation describes ExecutionEngineException as:
"The exception that is thrown when there is an internal error in the
execution engine of the common language runtime. This class cannot be
inherited.

Execution engine errors are fatal errors that should never occur. Such
errors occur mainly when the execution engine has been corrupted or data is
missing. The system can throw this exception at any time. When possible,
the system throws an exception that provides more information than the
ExecutionEngineException exception."

ExecutionEngineException Class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemexecutionengineexceptionclasstopic.asp

2. I reviewed your description carefully, and I suspect that the problem
may be caused by using P/Invoke to call unmanaged API, especially the
"data" parameter. Please check which side (the caller or callee) should
allocate the memory for "data" to call tira_get_captured_data, and make
sure that you marshall the data properly. I believe the following MSDN
articles are helpful:

Consuming Unmanaged DLL Functions
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconConsumingUnmanagedDLLFunctions.asp

Marshaling Data with Platform Invoke
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconmarshalingdatawithplatforminvoke.asp

Marshal Class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemRuntimeInteropServicesMarshalClassTopic.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top