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

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

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

Projects:
 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")
            .Initialize
            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.




0
uscold
Asked:
uscold
  • 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):
  IClassA
  IClassB
  OcxEventA

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

The DistroWindows project
  The application class implements IClassB...

0
 
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.
0
 
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...
0
 
EDDYKTCommented:
use late binding on APScroll.vbp
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
technically, the answer was given (angelIII and EDDYKT), hence, I would say point split
0
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