我有一个由.NET类包装的VB6对象.据我所知,只需运行VB6库并在所需位置插入断点即可逐步执行VB6对象.
然而,这似乎并不适用于我的情况.我试图重新编译VB6对象并在我的.NET项目中重新引用它,但这似乎没有帮助.
我从哪里开始?有没有办法将Debugger.Launch()等效插入到VB6项目中?任何帮助,将不胜感激!!
解决方法:
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.