我有一个用 C++ 编写的 DLL 文件。我尝试在我的 C# 代码中使用 C++ DLL。 C++ 方法调用正确,但在处理完成后出错。
异常详情:
completed.System.ExecutionEngineException was unhandled Message=Exception of type 'System.ExecutionEngineException' was thrown.
最佳答案
这段代码我遇到了同样的问题:
[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”。
希望对某人有所帮助... 西蒙
关于c# - XXX.exe 中发生类型为 'System.ExecutionEngineException' 的未处理异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15925884/