views:

33

answers:

1

I am using some .NET assemblies another developer wrote for use from an older VB6 application. They are only used for some of our customers so I am using the Assembly.LoadFrom(file) method and invoking the methods. I am worried about unloading / releasing the objects after I make the calls. Do I need to do something explicitly, or will the garbage collector take care of it automatically?

+5  A: 

You can't unload an assembly.

(The closest you can come to that is loading it into an AppDomain that you then unload.)

Steven Sudit
Dynamically loading assemblies into a separate AppDomain is actually the correct design pattern. That way, if an unhandled exception is thrown in the dynamically loaded assembly, it is isolated from your application which loaded it. Furthermore, as Steven stated, you can shut down the dynamically loaded AppDomain when needed.
bporter