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

x
  • 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.
0
jbees12
Asked:
jbees12
1 Solution
 
PaulHewsCommented:
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:
http://www.devx.com/vb2themax/Tip/18426

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

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