Reload link on the fly (C # .NET)

Okay, that dictum ...

I have a service that is running and it is referencing a DLL that has changed a lot. This service will hopefully cause multiple clients to hit it right away, so it would be inefficient to close it and recompile / reload with a new link. I was wondering if, anyway, the program could pretty much automatically detect a DLL with a later version and just discard the old one and load the new one without closing it.

+2


source to share


3 answers


This can be difficult to achieve in a .Net application. When the DLL is loaded into a specific AppDomain, there is no way to unload the DLL from the AppDomain. The only way to get the DLL out of the process is to unload the AppDomain itself.



You could achieve what you are trying to achieve by loading the DLL into a secondary AppDomain and restarting that AppDomain with a new DLL when changes are detected. It also has to do with the use of some advanced shadow copying functionality, though so that the DLL can be removed when used by the process.

+4


source


The only way to do this is to move the code that uses the assembly to its own AppDomain. You can disable AppDomain and restart it with a new build.



See this question: How to reload an assembly in C # for a .NET domain?

0


source


The Managed Extensibility Framework allows you to do this.

0


source







All Articles