简体   繁体   中英

Unload DLL after loading with Assembly.LoadFrom()

In my project I am loading a DLL using reflection and Assembly.LoadFrom() . This is a small DLL that is occasionally recompiled (from the source) dynamically during application execution.

Is there a way to unload the loaded DLL from the application so that I can reload it? I've tried reloading it, but I get an error:

file in use by another program

If the application that has the file open is a custom app, then you could modify it to load the DLL into another AppDomain. When you want to reload it, simply tear down that AppDomain and load the new DLL into the new AppDomain. I'd have a look at MEF (which does this) to see whether this might support your use case.

You can't. You have to kill the program. There is no way to unload an assembly in .Net.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM