Cross IDE Debugging - VB.Net to VB6

S

Sean Kirkpatrick

I'm sure you'll look at this question and wonder if I've been sniffing
glue. I haven't, really.

My legacy app is written in VB6 and we're chipping away at converting it
to .Net. I badly need to be able to step from VB6 IDE into a running
VB.Net session to debug the .Net component. This is trivial if I'm
running a compiled VB6 app, but that doesn't get me what I need.

Can I cross the IDE boundary like this?

Sean
 
D

David Browne

Sean Kirkpatrick said:
I'm sure you'll look at this question and wonder if I've been sniffing
glue. I haven't, really.

My legacy app is written in VB6 and we're chipping away at converting it
to .Net. I badly need to be able to step from VB6 IDE into a running
VB.Net session to debug the .Net component. This is trivial if I'm running
a compiled VB6 app, but that doesn't get me what I need.

Can I cross the IDE boundary like this?

Yes. In VB.NET just attach to the VB6 IDE's process.

David
 
C

Chris

Sean said:
I'm sure you'll look at this question and wonder if I've been sniffing
glue. I haven't, really.

My legacy app is written in VB6 and we're chipping away at converting it
to .Net. I badly need to be able to step from VB6 IDE into a running
VB.Net session to debug the .Net component. This is trivial if I'm
running a compiled VB6 app, but that doesn't get me what I need.

Can I cross the IDE boundary like this?

Sean

Never tried it that way, but if you launch your VB6 app and then go to
Visual Studio and choose Tools -> Debug Process. Attach to the VB6
process and you should be able to put a break point in your .net app.

Chris
 
H

Herfried K. Wagner [MVP]

Sean,

Sean Kirkpatrick said:
My legacy app is written in VB6 and we're chipping away at converting it
to .Net. I badly need to be able to step from VB6 IDE into a running
VB.Net session to debug the .Net component. This is trivial if I'm running
a compiled VB6 app, but that doesn't get me what I need.

Can I cross the IDE boundary like this?

Yes, that's actually possible. Just create your VB6 project and your VB.NET
projects (a class library, for example) and reference the VB.NET project
from your VB6 project. Create a debug build of your VB.NET project.

To debug the projects together, open both projects, the VB.NET class library
project in VS.NET and the VB6 project in the VB6 IDE. Set breakpoints in
the class library project. Then start the VB6 EXE project from within the
VB6 IDE. Switch to VS.NET and choose "Debug" -> "Processes..." and select
"VB6.EXE". If the VB6 application is not started from within the IDE,
choose its EXE file from the list. Now you can debug the VB.NET class
library within VS.NET. If execution reaches a breakpoint, for example, it
will be highlighted in VS.NET and execution will be stopped until you
continue execution.
 
S

Sean Kirkpatrick

Thanks all - I see how it's done. Unfortunately, both IDEs crash when I
try to step into the .Net project. I submitted a crash report and MS
says that the problem is most likely caused by the .Net Framework 1.1. I
installed the lastest .Net service pack but nothing changed. :(

Sean
 
P

Peter Huang [MSFT]

Hi

I assume you are call .NET exposed COM object from vb6.
I think you may try to follow the steps below debuging vb6 app in vs.net.
1. Compiled the VB6 with Create Symbols
2. Set the Startup program when debugging for the VB.NET dll with the VB6
project1.EXE and check the unmanaged debugging option in the project
setting.
3. Open the Form1.frm in the vb.net IDE
4. Set break point in the Form1.frm's code line
5. F5 to run the VB.NET DLL project, because we have set the VB6
project1.EXE as the start up program, it will be run to hit the break point
in the Form1.frm
e.g.
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1800
TabIndex = 0
Top = 1320
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim o As New TestCrossDebugVB6.MyTestClass
Dim s As String
s = o.TestString() 'If we set break point here, it will be hit when we
click Command1
MsgBox s
End Sub

[VB,NET]
Imports System.Runtime.InteropServices
<ClassInterface(ClassInterfaceType.AutoDual)> _
Public Class MyTestClass
Public Function TestString() As String
Return "Hello World"
End Function
End Class


You may have a try.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top