看板 C_Sharp 關於我們 聯絡資訊
目前已完成: 1. 已使用C在a專案產生DLL,並且在b專案(cpp)載入並使用 2. 在專案c(c# form)裡加入a專案的dll [DllImport("Win32Project2.dll", EntryPoint = "Add")] public static extern int Add(int a, int b); 3. 直接點c專案的.exe (dll也放在一起) 可以正常執行 問題: 用偵錯模式(F5)跑到dll中的function時會出現以下錯誤: Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'D:\test_code\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe'. wsFormsApplication1.vshost.exe' Additional information: 對 PInvoke 函式 'WindowsFormsApplication1! 我應該是載入成功了但為何只有debug模式會出錯呢? 懇請各位大大賜教 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.166.182.8 ※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1449552654.A.71D.html
fo40225: C++的function加上 __stdcall 或CallingConvention.Cdecl 12/08 21:51
hardman1110: 請問是加在dll的專案嗎? 敢問原理是? 12/08 22:35
james732: 拿一樓的關鍵字去google看看? 12/09 10:44