Results 1 to 27 of 27

Thread: [RESOLVED] ActiveX dll's that reference each other

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2019
    Posts
    416

    Resolved [RESOLVED] ActiveX dll's that reference each other

    Is this possible?

    EDIT

    This is related to the discussion on assume no aliasing. I have a customized version of cHashD that is strongly typed for a string key and a class type.

    So I made a sep dll for the chashHD but of course it need to reference that other dll with the class type in it and the other dll needs to ref the dll with clsHashD in it. Getting tied up in knots here.

    Don't think this is possible...
    Last edited by vbwins; Aug 4th, 2022 at 01:59 AM.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: ActiveX dll's that reference each other

    Use latebinding?
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2019
    Posts
    416

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Zvoni View Post
    Use latebinding?
    But then I need to pass to classes as variant and I loose the strongly typed performance opt as stuff has to be coerced to variant.

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: ActiveX dll's that reference each other

    hmm....what about swapping out that "type" into a support-Ax-DLL, so both dll's can reference that type in that dll, and the second dll then only needs to reference the first one?
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: ActiveX dll's that reference each other

    So you now have project A with some custom VB6 classes and project B with cHashD and need B to reference A for the cHashD to return items of A class types but then you need A to reference B for A want to use cHashD instances. This dependency graph looks like this

    Code:
    A <--> B
    You can try transforming it to this

    Code:
    A <-- B
    |
    v
    C
    So cHashD sees all the types from A and can return items of A class types while A does not reference B but a separate *type library* C which has an interface which cHashD implements which could be even default _cHashD interface redeclared or it could be a specialized IHashD interface which cHashD explicitly implements.

    cheers,
    </wqw>

  6. #6
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by wqweto View Post
    So you now have project A with some custom VB6 classes and project B with cHashD and need B to reference A for the cHashD to return items of A class types but then you need A to reference B for A want to use cHashD instances. This dependency graph looks like this

    Code:
    A <--> B
    You can try transforming it to this

    Code:
    A <-- B
    |
    v
    C
    So cHashD sees all the types from A and can return items of A class types while A does not reference B but a separate *type library* C which has an interface which cHashD implements which could be even default _cHashD interface redeclared or it could be a specialized IHashD interface which cHashD explicitly implements.

    cheers,
    </wqw>
    Eh? So i was actually pretty close.....
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  7. #7
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Zvoni View Post
    Eh? So i was actually pretty close.....
    No, you got it all reversed while I was posting my reply :-))

    You keep A-->B but then make a new B-->C which might be way to much effort -- C now has to have all the class types from A which can be hundreds of different business objects which OP keeps in collections.

    If it wasn't tricky I wouldn't have bothered to post in first place :-))

    cheers,
    </wqw>

  8. #8
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by wqweto View Post
    No, you got it all reversed while I was posting my reply :-))
    cheers,
    </wqw>
    For me, THAT is close.... :-)
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  9. #9
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by vbwins View Post
    Is this possible?

    EDIT

    This is related to the discussion on assume no aliasing. I have a customized version of cHashD that is strongly typed for a string key and a class type.

    So I made a sep dll for the chashHD but of course it need to reference that other dll with the class type in it and the other dll needs to ref the dll with clsHashD in it. Getting tied up in knots here.

    Don't think this is possible...
    I never did but I don't see a problem. Did you try?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2019
    Posts
    416

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Eduardo- View Post
    I never did but I don't see a problem. Did you try?
    Yes I tried. Failed. And I suspect that it gets properly impossible when you want to change the interface of one of the DLL's

    I think then you will be in a situation where you cant compile one without compiling the other.

  11. #11
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by vbwins View Post
    Yes I tried. Failed. And I suspect that it gets properly impossible when you want to change the interface of one of the DLL's

    I think then you will be in a situation where you cant compile one without compiling the other.
    Ah, it fails to compile when the two projects are opened in a group. But compiled individually they should work, I guess.

  12. #12
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Eduardo- View Post
    Ah, it fails to compile when the two projects are opened in a group. But compiled individually they should work, I guess.
    How if it cannot solve the dependency because the other dll is (still) not compiled?
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  13. #13
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: ActiveX dll's that reference each other

    Compile both first, without a reference to the other (so lacking some of the properties/methods)
    Then you can add a reference from A->B
    And you can add a reference from B->A

  14. #14
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Arnoutdv View Post
    Compile both first, without a reference to the other (so lacking some of the properties/methods)
    Then you can add a reference from A->B
    And you can add a reference from B->A
    Exactly. That was the idea. To compile a first version without the dependency. And then, try to add the dependency and compile one at a time.
    But anyway I don't like this idea. I would try to avoid doing this cross dependency.

  15. #15
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,418

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Arnoutdv View Post
    Compile both first, without a reference to the other (so lacking some of the properties/methods)
    Then you can add a reference from A->B
    And you can add a reference from B->A
    How if he needs a Type provided by the "other" DLL?
    Or do you mean as a "dummy" (a.k.a. empty dll)?
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  16. #16
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: ActiveX dll's that reference each other

    Yes indeed, start with a barebone interface.
    When you have the references you can add new interfaces without problems

    But I would use 3 ActiveX dlls.
    One main DLL for the shared types etc. And probably for some shared other interfaces.
    Then the 2 other DLLs for their specific needs.

  17. #17
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Zvoni View Post
    How if he needs a Type provided by the "other" DLL?
    Or do you mean as a "dummy" (a.k.a. empty dll)?
    You compile the first DLL that is not depending on the still not compiled (or existent) second DLL.
    Then compile the second DLL with dependency to the first.
    Then add the dependency on the first DLL to the second and compile it again, now with the dependency to the second.

  18. #18
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    557

    Re: ActiveX dll's that reference each other

    Circular dependencies! Welcome to Hell :-)

    It is wonderful experience when you clone source of A and B and there are missing those initial simple binary dependencies) and current version of sources does not allow to create them easily.

    "Wait, I will copy it from MY MACHINE so you can compile" - everyone who worked in team have heard something similar for some buggy projects that someone in the team created with the mind of great excellence and "advanced code" of using only two libraries and not add third one.

    When you work alone and you can "remember" that you did this or that, source control is something bad and not compatible with your "working style", then doing all these actions may seem possible. But time passes, memory fades, computers are changed, binary folders are cleaned because of some other projects did not compile and BOOM - our A and B projects also fail to compile after the cleanup! Here they come - cyclic references FTW!

    Someone may put the initial small binaries in a folder, keep them in the source control, but the build cycle to reach successful compilation of the current version is still tricky without the right tooling and build scripts.

    Note: some other languages were created with the mind of circular dependencies and all that is handled by the compiler and other tooling. But they have that feature by design and some coding patterns are built upon this design.

  19. #19
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: ActiveX dll's that reference each other

    Personally, I think Zvoni had the correct answer, late binding. However, this does require a bit of hoop-jumping, but I've been doing it for years in my main project (used daily in many locations).

    Here's a link to the code I use to instantiate a class from an unregistered ActiveX DLL.

    You just have to remember to call UnloadActivexDll when you're done, or the library will stay in memory. Example is shown in the link.

    Using this approach, you can have all the circular ActiveX DLL references you want, because it's not dependent on anything being registered.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  20. #20
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: ActiveX dll's that reference each other

    Late-bindings undermines the very purpose because he used that class due to the performance advantage of strong-typing.

    Quote Originally Posted by peterst View Post
    Circular dependencies! Welcome to Hell :-)
    Yes, not a good idea at all, but possible, it is possible.

  21. #21
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Eduardo- View Post
    Late-bindings undermines the very purpose because he used that class due to the performance advantage of strong-typing.
    I thought he used that class (i.e., DLL) to get the performance advantages of optimization flags. You still get that with late binding. I use late binding with my smoothing algorithm, and it works absolutely fine, still giving me the performance boost. Admittedly though, I'm not calling the DLL's class's members in a loop though.

    Code:
    
    
    ' Code at top of module:
    Dim oContour As Object                  ' Separate DLL to make image colorful.
    
    
        ' Code in Form_Load (loading "optimized" ActiveX DLL):
        Set oContour = NewObjectFromActivexDll(DependenciesFolder & "Contour.dll", "clsContour")
    
    
        ' Code in specific processing spot to do the work.  Both bbEnlarged and bbFrame are byte arrays of the image.
        oContour.bbDoContouring bbEnlarged, bbFrame
    
    
        ' Code in Form_Unload:
        Set oContour = Nothing
        UnloadActivexDll DependenciesFolder & "Contour.dll"
    
    
    
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  22. #22
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Elroy View Post
    I thought he used that class (i.e., DLL) to get the performance advantages of optimization flags. You still get that with late binding. I use late binding with my smoothing algorithm, and it works absolutely fine, still giving me the performance boost.
    With late-binding you lose performance.

  23. #23
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Eduardo- View Post
    With late-binding you lose performance.
    Only on the actual call to get into whatever member you're calling. If we're not in a loop making calls into the DLL, that's negligible. The compiler optimizations will be the same either way (early or late bound).
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  24. #24
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: ActiveX dll's that reference each other

    Isn't the obvious solution, to put both Classes into the same Dll-Project?

    Olaf

  25. #25

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2019
    Posts
    416

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by Schmidt View Post
    Isn't the obvious solution, to put both Classes into the same Dll-Project?

    Olaf
    One class (A derivative of chashd) needs to be compiled without assume no aliasing

  26. #26
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: ActiveX dll's that reference each other

    Quote Originally Posted by vbwins View Post
    One class (A derivative of chashd) needs to be compiled without assume no aliasing
    And the other one cannot be compiled with exactly the same compiler-settings because...?

    I mean, the whole RC6.dll (with 100+ Classes) is compiled this way
    (all extra-compiler-Flags on, only the "top-one" off).

    Olaf

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2019
    Posts
    416

    Re: ActiveX dll's that reference each other

    And the other one cannot be compiled with exactly the same compiler-settings because...?
    That's where I ended up anyway.
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width