XXX 中发生了类型 'System.ExecutionEngineException' 的未处理异常.exe

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

本文关键字:未处理 异常 exe ExecutionEngineException System 发生了 XXX 类型      更新时间:2023-10-16

我有一个用c++编写的DLL文件。我试图在我的c#代码中使用c++ DLL。c++方法被正确调用,但在进程完成后给出错误。

Exception Details:

completed.System。未处理ExecutionEngineException消息=类型为"System"的异常。ExecutionEngineException"是抛出。

我在这段代码中遇到了同样的问题:

    [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() : "";
}

问题是"out"关键字。MSDN上的示例没有'out'。

希望这能帮助某人…西蒙。