Thursday 15 March 2012

c# - P/Invoke throw System.ExecutionEngineException -


I have a closed source coded in C ++, which I wanted to use in the C # solution, Managed DLL created using P / AWA to call closed source DLL function. It works very well for any ultimate function and variable variables although I get a system. Execution Engine Exceptions When Runs More Complex Functions That Takes an Array of the Composition There are four arrays for the wire. Here's what I have:

  [Structure layout (layout kick.security)] Public structure target {public perfection target; Public string label; } [DllImport ("tyrfde.dll", EntryPoint = "TrafficGet target")] Public stable extern int GetTarget (referee target [] goal);  

The information below is from the helit file DLL:

  #define TARGET_LBL_SIZE (256l) typedef struct _tyrfdeTarget {TInt32 TargetID; // Integer signed 32bits TCharA label [TARGET_LBL_SIZE]; // carat} tyrfdeTarget; TInt32 __stdcall tyrfdeGetTargets (tyrfdeTarget * pTargets);  

Not sure exactly why the size of the array is long, but SizeConst only int. After some searching I am trying to fix it.

But I still have problems I have read that if the work of memory used by CLR is clear, then it throws an exception. Unfortunately I can not verify this. Is there anything in my code that is clearly wrong and can cause problems?

Hm, I think your problem riff target [] target parameter AFAIR is a reference to this one reference, which is probably not what you really want.

I will try:

  [DllImport ("tyrfde.dll" EntryPoint = "tyrfdeGetTargets")] Public stable extern int GetTarget ([Out, Marshall AS (UnmanagedType .LPArray)] goal [] goal);  

Maybe it helps in making the right announcement.

Note that the size of the array is not clear here, usually in such a case a referee int length parameter, which is martialas in the attribute SizeParameterIndex can be referred to in property.


No comments:

Post a Comment