日期:2014-05-19  浏览次数:20756 次

调用delphi的dll,*.vshost.exe退出后有"读内存错误"
c#里调用自写的delphi7的一个dll
C#声明如下:
[DllImport( "PB2RM.dll ",   EntryPoint   =   "NewReportLOCAL ")]
public   static   extern   int   NewReport(string   templatefile,   string   tablexmlfile,   string   fieldxmlfile,   string   valuexmlfile);

delphi声明如下:
function   NewReportLOCAL(atemplatefile:pchar;tablexml:pchar;fieldxml:pchar;valuexml:pchar):integer;stdcall;export;          

为什么在vs2005里运行程序,关闭程序后*.vshost.exe退出后有 "读内存错误 ",而运行debug\*.exe,完全正常.
另外,这个dll在delphi,在pb的程序里调用也完全正常.
请问,这个 "读内存错误 "问题可能出在vs2005,还是c#,还是dll里?

------解决方案--------------------
这种问题很难确定源头

建议通过逐步排除的方法来寻找

把宿主进程关闭掉看看

项目属性-> 调试-> 启动调试器
取消启用Visual Studio宿主进程

如果Release版本不出问题就成
------解决方案--------------------
up
------解决方案--------------------
*.vshost.exe 是调试的时候支持.net环境的。调试时不能关这个进程