Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • 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.

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

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