2013-04-10 156 views
4

我有一個用C++編寫的DLL文件。我嘗試在C++代碼中使用C++ DLL。 C++方法被正確調用,但在處理完成後會出錯。在XXX.exe中發生未處理的類型爲「System.ExecutionEngineException」的異常

異常詳細信息:

completed.System.ExecutionEngineException了未處理 類型 'System.ExecutionEngineException' 的消息=例外是 拋出。

+0

這將有助於如果你能向我們展示了'ExecutionEngineException'的'Message'和'StackTrace'領域。 http://msdn.microsoft.com/en-sg/library/system.executionengineexception.aspx – 2013-04-10 12:33:39

+0

你有一個C++ DLL的調試版本嗎?如果是的話,你可以調試它。您還可以使用Microsoft Debugging Tools for Windows來創建應用程序轉儲。 – Siraf 2013-04-10 16:58:16

+1

這通常意味着非託管DLL中存在內存損壞錯誤,並且正在破壞引擎。 – 2013-04-11 14:09:57

回答

0

我得到這個代碼相同的問題:

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

的問題是 「走出去」 的關鍵字。 MSDN上的示例沒有「out」。

希望幫助別人...... 西蒙

相關問題