目前已完成:
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模式會出錯呢? 懇請各位大大賜教