• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1346
  • Last Modified:

Replace DLL while application is running

Is it possible to update a DLL while a service is running that uses the DLL ? Or does the service have to be stopped before the DLL can be replaced.
0
acousticsatelite
Asked:
acousticsatelite
1 Solution
 
athapaCommented:
If it is in use by the service then you can't replace the dll. If you just need to replace the dll but don't need to use the new dll then your service could copy the dll to temp location and load from there in the startup. So the actual dll can be replaced. But if you want to be able to update and load a new dll without restarting your app then you should try to load the dll in different appdomain. Whenever you need to update the dll, close the appdomain, change the dll, create a new appdomain, and load the dll in the new appdomain.

AT
0
 
AgariciCommented:
you can change the dll while the app is runing only if you load the dll at runtime into a different appdomain.

appDomain = AppDomain.CreateDomain("MyNewDomain");
assembly = appDomain.Load("dllToLoadDyn");
SomeType = assembly.GetType( "dllToLoadDyn.SomeType" );

// do whatever with the dll

AppDomain.Unload( appDomain );

hth,
A.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now