gpt4 book ai didi

c# - 单步执行 .NET 类包装的 VB6 COM 对象

转载 作者:太空狗 更新时间:2023-10-30 00:34:52 24 4
gpt4 key购买 nike

我有一个由 .NET 类包装的 VB6 对象。据我所知,可以通过简单地运行 VB6 库并在所需位置插入断点来单步执行 VB6 对象。

但是这在我的案例中似乎不起作用。我试图重新编译 VB6 对象并在我的 .NET 项目中重新引用它,但这似乎没有帮助。

我从这里去哪里?有没有办法将等效的 Debugger.Launch() 插入到 VB6 项目中?任何帮助将不胜感激!!

最佳答案

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.

关于c# - 单步执行 .NET 类包装的 VB6 COM 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6367332/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com