作者hardman1110 (笨小孩)
看板C_Sharp
标题[问题] C# 使用C产生的DLL
时间Tue Dec 8 13:30:51 2015
目前已完成:
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://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1449552654.A.71D.html
1F:→ fo40225: C++的function加上 __stdcall 或CallingConvention.Cdecl 12/08 21:51
2F:→ hardman1110: 请问是加在dll的专案吗? 敢问原理是? 12/08 22:35
3F:推 james732: 拿一楼的关键字去google看看? 12/09 10:44