Adding a Reference At Runtime

Posted on 2005-05-09
Last Modified: 2010-05-02
Is it possible to add and remove a reference at runtime?  I have an app that needs to access a class in a com object when the program starts up, but needs to remove the reference from it after it is finished so it can copy a new version of the dll from the server to the pc it is running on.
Question by:jbees12
    1 Comment
    LVL 38

    Accepted Solution

    As far as I know it isn't possible to add or remove a reference at runtime.  However, you should be able to use late binding to do the same thing:

    Dim MyClass as Object

    Set MyClass = CreateObject("Projectname.ClassName"")

    Call MyClass.MySub()

    If the new version of the DLL breaks compatibility, you will need to register it, which you can do by calling the DLLRegisterServer function in the DLL:

    There are other methods to register or unregister COM components.  Let me know if you need more.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now