An unhandled exception of type 'System.ExecutionEngineException' occurred in XXX.exe

我怕爱的太早我们不能终老 提交于 2019-12-10 18:46:41

问题


I have a DLL file that is written in C++. I am try to use in C++ DLL in my c# code. C++ method is called correctly but it gives error after process completed.

Exception Details:

completed.System.ExecutionEngineException was unhandled Message=Exception of type 'System.ExecutionEngineException' was thrown.


回答1:


I got the same problem with this code:

    [DllImport("camapi.dll", CharSet = CharSet.Unicode)]
private static extern CSTATUS_T CWRAPPER_GetFriendlyName(IntPtr pCameraBus, string sCamID, out StringBuilder sFriendlyName, 
                                                         uint uBufferSizeInWords);

public static string CWRAPPER_GetFriendlyName(IntPtr pCameraBus, string sCamID)
{
    var sFriendlyName = new StringBuilder(256);
    var status = CWRAPPER_GetFriendlyName(pCameraBus, sCamID, out sFriendlyName, (uint)s.Capacity + 1);
    return (status == CSTATUS_T.CSTATUS_SUCCESS) ? sFriendlyName.ToString() : "";
}

The problem was the "out" keyword. The example on MSDN doesn't have the 'out'.

Hope that helps someone... Simon



来源:https://stackoverflow.com/questions/15925884/an-unhandled-exception-of-type-system-executionengineexception-occurred-in-xxx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!