XXX.exe中发生了未处理的“System.ExecutionEngineException”类型的exceptionexception

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

例外细节:

completed.System.ExecutionEngineException未处理Message =抛出了类型’System.ExecutionEngineException’的exception。

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

  [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’。

希望有人帮助……西蒙