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

Adding a Reference At Runtime

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.
1 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.
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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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