我可以只使用 VS2013 单步执行 VB6 代码吗?

Can I step through VB6 code with VS2013 exclusively?

我最近继承了一个旧的 VB6 项目,其中包含构建的二进制文件、源代码、项目文件等,但没有 pdb 文件。有什么方法可以启动这个 VB6 应用程序并使用 VS2013 工具逐步完成它?或者我需要安装 VB6 IDE?

如果您可以获得 VB.NET 2003、2005 或 2008 的副本,即 VB.NET 的版本能够将 VB6 项目转换为VB.NET 项目。 VB.NET 之后的版本不会在 VB6 项目上 open/operate。

因此,您的选择是 VB 6,或者 VB 2003、2005 或 2008(或者 VB.Net 的现代副本...转换一下代码,希望不是什么大应用。)

您不能直接在 VS .NET 中按原样打开 VB6 项目。

但是你想到的可能是通过Visual Studio调试编译好的VB6的程序;假设您可以重新编译 VB6 模块以包含 PDB 文件,这是可能的。如果没有它们,我认为这不会很好地发挥作用,如果有的话。

Debugging VB6 binaries in Visual Studio .NET, by robgruen November 9, 2004

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” [or "enable native code 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.

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.