• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 488
  • Last Modified:

VB6: Problem in Compiling an ActiveX ocx & ActiveX exe having circular ref.

I have a problem in compiling two VB projects that was delivered to us by a third party.
Here are the details:
Windows 2000 Server service pack 4
VB6 service pack 5

 a. APScroll.vbp --> compiles to an ocx (AP.ocx)
 b. DistroWindows.vbp  --> compiles to an ActiveX exe (DistroWindows.exe)

The two projects have a circular reference, in that
1. APScroll.vbp creates a class CostDist, declared in DistrowWindows.exe and passes the reference of WFXShellUC to CostDist.
2. DistroWindows.vbp refers to a UserControl (Name: WFXShellUC) that is defined in APScroll.vbp

   Here's the code in the user control WFXShellUC:
   Public WithEvents d As CostDist.clsCostDistDlg
       Set d = New CostDist.clsCostDistDlg
        With d
            Set .ctlRef = Me
            MsgBox ("Set Control Reference")
            MsgBox ("Initialized")
        End With

Here is the procedure I followed:
1. compile DistroWindows.exe
      (refer to an existing ap.ocx)
2. Add project references to DistroWindows.exe compiled in step 1 in APScroll.vbp and compile APScroll.vbp to ap.ocx.
3. The compile in step2 fails with the link error saying "cannot replace object ap.ocx)
    I guess  the reason being DistroWindows.exe (added to project references of APScroll) intern refers to AP.ocx that we are trying to replace.

Any help in getting these two projects compiled is appreciated.
If needed I can email the two projects and dependent files.

  • 3
2 Solutions
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you cannot have circulare reference in projects, you have to use a third project as intermediate through which you make the calls, or the third project contains the Interface classes which the other 2 project classes implement respectively and call respectively.
In case of OCX, which probably has some events, the RefProject should have a OcxEventSink class, which the OCX has as property object, which actually sends the events out.

RefProject (ActiveXDLL), contains the following classes (sample):

The APScroll project:
  OP.ocx -> implement IClassA, and has a property object of type OcxEventA

The DistroWindows project
  The application class implements IClassB...

uscoldAuthor Commented:
do u have an example code for this?

Also the project (compiled versions) are currently running in production.
This was delivered by a 3rd party who had actually written and installed it in production and it is running fine.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
no. as I left my previous job where I had such a case, I was (obviously) not allowed to take a copy...
use late binding on APScroll.vbp
Guy Hengel [angelIII / a3]Billing EngineerCommented:
technically, the answer was given (angelIII and EDDYKT), hence, I would say point split
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now