我有一个用 C++ 编写的 DLL 文件。我尝试在我的 C# 代码中使用 C++ DLL。 C++ 方法调用正确,但进程完成后出现错误。
异常详细信息:
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”。
希望能帮助某人...
西蒙
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)