通过.NET类包装的VB6 COM对象 [英] Stepping through VB6 COM object wrapped by .NET Class

查看:134
本文介绍了通过.NET类包装的VB6 COM对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由.NET类包装的VB6对象。据我所知,只需运行VB6库并在所需位置插入一个断点就可以通过VB6对象(编译为库)。



但是,在我的情况下这似乎并不奏效。我已经尝试重新编译VB6对象,并在我的.NET项目中重新引用它,但这似乎没有帮助。



我从哪里去?有没有办法在VB6项目中插入相当于$ code Debugger.Launch()?任何帮助将不胜感激!

解决方案

robgruen的博客



如果您正在使用互操作调用进入VB6 ActiveX dll或exe,您需要调试VB6项目,您可能会发现自己同时拥有VS.NET和VB6 IDE。通常您将VB6项目设置为等待组件创建,并启动.NET应用程序,然后再打破断点。在VB6组件中。那么有一个更简单的方法来做到这一点。您可以在VS.NET中实际调试VB6组件。这是您需要做的:



1)使用符号构建您的VB6项目。在VB6中打开您的vbp文件,转到项目 - >属性。选择编译选项卡并选中编译本机代码,然后选择无优化单选按钮并选中创建符号调试信息。



这将生成一个。 PDB(程序数据库)文件以及.EXE文件。该文件包含调试信息,所以VS.NET调试器可以排列源和命中断点等(确保您的VB6 dll集合具有二进制兼容性,或者您必须删除并重新添加对VB6的引用VS.NET中的组件。)



2)在VS.NET中打开.NET项目。 3)转到项目属性并选择配置属性 - >调试属性页并启用非托管调试。对于VB.NET项目,此选项是非托管代码调试,而C#是启用非托管调试。



4)选择解决方案的属性页。



5)添加到调试源文件一个指向VB6组件源代码路径的条目。



6)添加到Debug Symbols Files中的条目,该条目指向在步骤1中生成的.PDB文件的文件夹。



7)您现在应该可以在VS.NET中打开.bas,.cls,.frm等文件,并且可以在文件中放置断点。一旦您调试调试器将停止在这些代码行。


I have a VB6 object that is wrapped by a .NET class. As far as I recall it is possible to step through a VB6 object (compiled as a library) by simply running the VB6 library and inserting a breakpoint at the desired location.

However this does not appear to be working in my case. I have attempted to recompile the VB6 object and re-reference it in my .NET project but this doesn't appear to have helped.

Where do I go from here? Is there a way to insert Debugger.Launch() equivalent into a VB6 project? Any help would be appreciated!!

解决方案

Lifted from robgruen's blog:

If you are using interop to call into a VB6 ActiveX dll or exe and you need to debug your VB6 project you may find yourself having both VS.NET and the VB6 IDE open. This can certainly be far from efficient.

Typically you set your VB6 project to "Wait for the Component to be created" and you launch your .NET app and then hit breakpoints within the VB6 component. Well, there’s an easier way to do this. You can actually debug your VB6 component within VS.NET. Here’s what you need to do:

1) Build your VB6 project with symbols.In VB6 open up your vbp file and goto "Project->Properties." Select the "compile" tab and check "Compile to Native Code." Then select the "No Optimization" radio button and check "Create Symbolic Debug Info."

This will generate a .PDB (Program Database) file along with your .EXE. This file contains the debugging information so the VS.NET debugger can line up source and hit breakpoints, etc. (Make sure you have binary compatibility on your VB6 dll set or you’ll have to drop and re-add your reference to the VB6 component in VS.NET.)

2) Open your .NET project in VS.NET.

3) Go to the project properties and select the "Configuration Properties->Debugging" property page and enable unmanaged debugging. For VB.NET projects this option is "Unmanaged code debugging" and for C# is "enable unmanaged debugging."

4) Select the property page for the solution.

5) Add to the "Debug Source Files" an entry that points to the path where the source code is for the VB6 component.

6) Add to the "Debug Symbols Files" an entry that points to the folder where the .PDB file is that was generated in step 1.

7) You should now be able to open your .bas, .cls, .frm, etc. files in VS.NET and you can put breakpoints in the file. Once you debug the debugger will stop on those lines of code.

这篇关于通过.NET类包装的VB6 COM对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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