Trax
Trax

Reputation: 1033

How to debug an application which is started from an another application ? (VB6)

Imagine that when i start application #0, it makes some calculations and after some time it starts application #1, application #2, application #3. (It sends some arguments, object to new applications.).

I want to debug application #1 but it must be started from application #0.

How can i do this? (I'm using Visual Studio 6 & i have the source code & everything about these applications)

Upvotes: 3

Views: 1818

Answers (2)

djv
djv

Reputation: 15774

Read this article which describes how to debug an ActiveX exe

Basically you will run the ActiveX exe, then add a reference to it in the calling application. Leave the ActiveX exe running because the reference is to its running process, not to its compiled exe. Now run the calling application as well. This will allow you to stop on breakpoints in separate instances of visual studio.

It has been a while but I wanted to make sure I could do it myself, and I can confirm it works. So here it is:

Make a new project called Project1. It will be the ActiveX EXE

enter image description here

You should have a file called Class1, where you will put this code:

Option Explicit

Public Function Foo()
    MsgBox "foo"
End Function

Now make another project called Project2. This is a standard EXE

enter image description here

Start Project1. This prompt asks what to do when the project starts. Choose "Wait for components to be created". Click ok and leave it running.

enter image description here

Go to Project2, Project Menu >> References. Find Project1 in the list. Tick the checkbox. (Do not browse the file-system to Project1 at this point, just use the temporary binary in the available references list!)

enter image description here

Now enter this code in Project2.Form1

Option Explicit

Private Sub Form_Load()
    Dim p As New Project1.Class1
    p.Foo
End Sub

You may put a breakpoint in Project1.Class1.Foo() on the msgbox line. This breakpoint will be hit when you run Project2.

The reference you added is strictly used for debugging. When deploying your application, you should copy the ActiveX exe binaries to your application directory and reference those files directly.

Upvotes: 5

jveazey
jveazey

Reputation: 5468

Microsoft has published a couple of articles somewhat related to this, but it states that you have to start VB6.exe as the child process instead of your compiled VB6 program.

Upvotes: 0

Related Questions