Assembly.LoadFrom(...)

H

Henrik de Jong

I'm using a sort of plugin mechanism in combination with a commandfactory
(pluginfactory). This factory looks in a special dir when it's starting.
Each assembly(*.dll) will be loaded with Assembly.LoadFrom(assemblyname).
After loading, it walks through all types in the assembly looking for a
info-object. When this info-object is found, then it should be a known
plugin-assemlby.

My question is how to unload these assemblies?

Kind regards,
Henrik
 
S

Scott Allen

Hi Henrik:

Unfortunately you can't unload an assembly. MS gives several reasons
for this, one being that the runtime can't be sure there isn't some
thread still executing code in the assembly. The runtime would also
have to go throw the memory heap used by the JIT and remove compiled
methods to completely unload an assembly, and the design just isn't
optimized for this scenario - it's optimized for adding new compiled
methods.

The workaround is to create a new application domain for your
plug-ins, and unload the app domain. This has a price to pay in
performance because you've introduced a remoting boundary.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top