调试调用.Net(C#)dll的VB6项目 [英] Debugging VB6 project that calls a .Net(C#) dll

查看:159
本文介绍了调试调用.Net(C#)dll的VB6项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题我已经呆了几个小时了。我希望有人遇到类似的问题。



我们已经开发了一个使用VS2010的原型.Net(C#)dll,并希望能够调用这个DLL在C#应用程序和VB6应用程序中。



我的问题是:



是否可以调试一个调用.Net dll的VB6应用程序?我收到一条错误消息自动化错误系统找不到指定的文件



错误信息表明有些东西我的VB6应用程序缺少找到.Net dll。



我知道如果VB6应用程序已经被编译,并且.exe​​已经被创建,VB6将在使用.exe时成功调用.Net dll功能



但是,我们可以通过VB6应用程序进行调试很重要。不幸的是,调试不允许您跨越代码实例化.Net DLL的类对象的代码行。我似乎无法做到这一点。



注意:我已经看过论坛和MSDN文档,我主要找到在.NET中调用VB6 dll的解决方案;这是不幸的是与我们需要做的相反。



注意:我已经注册了编译的.Net(C#)程序集,并在VB6项目中引用它。



然而,我发现这两个页面似乎是我们需要的,但它是一个使用VS2005生成的调用.NET(c#)DLL的解决方案。当使用VS2010生成.NET(C#)DLL时,这似乎不起作用。



site1
site2



如果有人可以给任何建议或指导我在某个地方可以得到一个,那将是伟大的。



谢谢



解决方案
感谢@HansPassant,我找到了解决方案。
要调试包含C#.NET程序集的VB6项目,您需要通过 regasm gacutil 注册.NET dll,然后在开始调试之前,请确保关闭并重新打开VB6应用程序。

解决方案

这不是问题,VB6使用自己的调试器,不妨碍任何其他调试器,包括C#代码管理的一个。



从C#类库项目开始,确保它被选为启动项目。项目+属性,调试选项卡。选择启动外部程序选项并输入到VB6 IDE的路径。通常c:\program files\microsoft visual studio\vb98\vb6.exe。在要调试的方法上设置断点。



按F5,VB6 ide将开始运行。加载或创建您的vb6项目。请注意如何在上一步中添加.vbp项目的路径,以便它自动加载您的项目。



像往常一样开始调试vb6项目。一旦开始使用您的[ComVisible] C#类,那么您的C#程序集将被加载。当您的vb6代码调用该方法时,断点将会触发。根据需要来回切换请注意,您不能从vb6到C#代码单步,您必须设置断点以使调试器停止。


I have been stump in this problem for a few hours now. I hope someone has had a similar problem to this.

We have developed a prototype .Net(C#) dll using VS2010, and would like to be able to call this dll in a both C# applications and VB6 application.

My question is:

Is it possible to debug a VB6 application that is calling a .Net dll? I get an error message "Automation Error The system cannot find the file specified"

The error message suggests that there is something missing for my VB6 app to find the .Net dll.

I am aware that if the VB6 application has been compiled, and the .exe has been created, the VB6 will successfully call the .Net dll functionality when using the .exe

However it is important that we can debug through our VB6 application. Unfortunately debugging does not allow you to step over the line of code instantiating the .Net DLL's class object. I can't seem to do this.

NOTE: I have looked around forums and MSDN documentation and I mostly find solution for calling a VB6 dll in .NET; which is unfortunately the opposite of what we need to do.

NOTE: I have already registered the compiled .Net(C#) assembly, and referenced it in the VB6 project.

I have however found these two pages, which seemed to be what we need, but its a solution for calling a .NET(c#) dll generated using VS2005. This doesnt seem to work when the .NET(C#) dll was generated using VS2010.

site1 site2

If someone could give any suggestions or direct me somewhere I can get one, that would be great.

Thanks

SOLUTION Thanks to @HansPassant, I have found the solution. To debug a VB6 project that contains a C# .NET assembly, you need to register the .NET dll through both "regasm" and "gacutil", then make sure to close and reopen the VB6 application before you start debugging.

解决方案

This is not a problem, VB6 uses its own debugger that doesn't get in the way of any other debugger, including the managed one for C# code.

You start from your C# class library project, ensure it is selected as the start project. Project + Properties, Debug tab. Select the "Start external program" option and enter the path to the VB6 IDE. Typically c:\program files\microsoft visual studio\vb98\vb6.exe. Set a breakpoint on the method you want to debug.

Press F5 and the VB6 ide will start running. Load or create your vb6 project. Note how you can add the path to the .vbp project in the previous step so it will automatically load your project.

Start debugging your vb6 project as usual. As soon as it starts using your [ComVisible] C# class then your C# assembly gets loaded. And the breakpoint will hit when your vb6 code calls the method. Switch back and forth as needed. Note that you cannot single-step from vb6 to C# code, you have to set breakpoints to get the debugger to stop.

这篇关于调试调用.Net(C#)dll的VB6项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆