[問題] C# 使用C產生的DLL

看板C_Sharp (C#)作者 (笨小孩)時間9年前 (2015/12/08 13:30), 編輯推噓1(102)
留言3則, 3人參與, 最新討論串1/2 (看更多)
目前已完成: 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

12/08 21:51, , 1F
C++的function加上 __stdcall 或CallingConvention.Cdecl
12/08 21:51, 1F

12/08 22:35, , 2F
請問是加在dll的專案嗎? 敢問原理是?
12/08 22:35, 2F

12/09 10:44, , 3F
拿一樓的關鍵字去google看看?
12/09 10:44, 3F
文章代碼(AID): #1MPciEST (C_Sharp)
討論串 (同標題文章)
文章代碼(AID): #1MPciEST (C_Sharp)