简体   繁体   中英

Need help on debugging of vb6 code that is used in .net application

My .Net Application is using some vb6 controls and libraries. I can not debug the vb6 code through my .net application. Can anybody help me out, how I can debug vb6 code that is using as user control in .net application.

Try this advice, found here

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.

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.”

3. Select the properties.

Add to the “Debug Source Files” an entry that points to the path where the source code is for the VB6 component.

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.

Disclaimer: I have not tried this myself.

I've done this many times, here's a good step by step article on how to do it on MSDN . Basically you just need to hit F5 from within VB6, and set your breakpoints in your VB6 code where you're investigating.

Next step in .NET make sure you're added a reference to the exact VB6 DLL that you just built, and run the .NET application, it should hit your VB6 breakpoint (remember VB6 app is still running you left it at F5)

I am not sure you can do it or not, but I have gotten some ideas from following link :

If you double-click My Project in Solution Explorer and go to the Debug tab you'll see an option that says "Start External Program." Select this option and type in "C:\\Program Files\\Microsoft Visual Studio\\vb6.exe." (with quotes).

After that, put the full path to your .vbp file in the command line arguments (also with quotes around it). Now when you run VS will fire up VB6, and the debugger's attached. You can then set and hit breakpoints in the normal way you're used to.

Alternately you can also do this using Tools->Attach to process, but personally I find the first approach easier. You set it up once and then you don't have to worry about it again.

One thing to watch for is if you hit Stop in VS2005, your VB6 program will exit without prompting you to save, so if you make any changes in your VB6 project make sure you click Save before pressing F5 (in VB6).

Hope that helps, please let us know if you have any issues with this.

You can not debug VB6 code in Visual Studio at any level higher than the compiled assembly code. If you had the source code you could convert it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM