Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reference a class from an EXE project?

Tags:

vb6

I am tasked with resurrecting a VB6 project and it has been too long since I worked with VB6.

Here is my problem.

Project A is an ActiveX EXE project. Within the same Project Group there is another ActiveX EXE project; Project B. Project B contains clsCommon (clsCommon.cls) that Project A needs to use, as in:

Private clsCommonA as ProjectB.clsCommon 

When I attempt to add Project B's output exe (not the vbp) to Project A's references, I get the error Project 'Project B.vbd' can not be referenced because it's project type is EXE.

Can someone please remind me how to reference classes inside of an EXE? (I am having no trouble with referencing classes in projects in the project group where the output is a ActiveX DLL)

BTW: I assume this is even possible only because some developer 20 years ago evidently had this working.

like image 803
davecove Avatar asked Jul 09 '19 18:07

davecove


People also ask

How to Add references to the project?

Add a reference In Solution Explorer, right-click on the References or Dependencies node and choose either Add Project Reference, Add Shared Project Reference, or Add COM Reference. (You can right-click the project node and select Add from the fly-out menu to choose from these options, too.)


1 Answers

VB6 does not allow you to add a reference to an ActiveX Exe (your ProjectB) from a project (ProjectA) that is loaded into the same IDE (project group). You get the error displayed when you try.

This is because an ActiveX Exe runs as a separate process, which I believe the VB6 IDE isn't capable of doing for separate projects in a group. So while it looks like you are adding the reference to ProjectB exe, since it's in the group, VB6 is actually adding a reference to ProjectB vbp, which isn't supported.

You need to remove ProjectB from your group. Then you'll be able to reference the ProjectB Exe from the ProjectA IDE.

If you need to run ProjectB in the IDE (for debugging or development), then first start VB6 and load ProjectB. Then start a second instance of VB6 and load ProjectA. When you start ProjectB, you'll notice that the reference in ProjectA changes from the ProjectB Exe to the ProjectB vbp (running in the second IDE). Set breakpoints in ProjectB as appropriate, then when you start ProjectA and instantiate ProjectB and make the method calls, you'll be running the ProjectB code in that IDE.

like image 64
MarkL Avatar answered Sep 18 '22 21:09

MarkL