c# - XXX.exe 中发生类型为 'System.ExecutionEngineException' 的未处理异常

标签 c# c++ dll unhandled-exception executionengineexception

我有一个用 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/

相关文章:

c++ - C++ 中是否可以使用仅堆栈变​​量?

c# - 是否可以使用 C# DllImport 从 DLL 导入非托管类或结构?

c# - 在运行时从另一个程序集加载 Controller

c# - 如何使用反射获取私有(private)字段的值?

c# - 将多个复选框绑定(bind)到 ViewModel 中的单个属性

c# - 如何解析包含 C# 列表的 Json WebApi 响应

c++ - 断开连接后正确杀死 asio steady_timer

c++ - C++ 中的 Lambda <-> 闭包等价

c++ - Excel VBA C++ .dll

php与dll通信?