Unloading assemblies

D

Dmitry Shaporenkov

Hi all,
I'm developing a tool that explores contents of
assemblies via reflection. When the tool is requested to
get some information from an assembly, it loads the
assembly and reads the information. I would like unload
the assembly immediately after to prevent it from locking
and give the client a possibility to update it. Is there
any way to do this? System.Assembly class has no Unload
method, so I create separate application domain and load
the assembly in this domain. Then I unload the entire
domain by AppDomain.Unload call. However it seems that
the loaded assemblies are still locked even after
unloading the domain.

Has anybody ideas about the reasons of such behavior? Or
can anyone suggest other ways to solve the problem?

Thanks,
Dmitry Shaporenkov
 
D

Dave

Make sure that you are doing all the reflection work in the other appdomain.
If you return references to types or assemblies from the other appdomain to
the default appdomain this has the effect of loading the assembly into both
appdomains.
 

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

Top