Unloading assemblies

  • Thread starter Thread starter Dmitry Shaporenkov
  • Start date Start date
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
 
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.
 
Back
Top