Unloading .NET dlls

I wrote a program that needs to be able to get new versions of it's own dll's through the internet.
The problem is that the old dlls which are used by the program are locked. I want to unload them, copy the new dlls, and then load them back for use by the program.

If it isn't prossible I'll probably have to write a second program which performs the update by shutting down my app, doing the dll update and then start my app again... But I really prefer doing it all in one app...

ArielLaubAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
CoolAssConnect With a Mentor Commented:
A single application (aka a single process) can have multiple AppDomains.

I suggest placing all updatable assemblies in a second AppDomain, and reserve the first AppDomain for the assemblies that contains the code that is responsible for updating the application.

Also, check out this article about self-updating applications:

http://www.gotdotnet.com/team/windowsforms/appupdater.aspx
0
 
CJ_SCommented:
The second program aapproach is normally being done.

You should:
- close the app.
- start the new app, initialize / copy all dll's.
- start the app again.

There is no other way.

CJ
0
 
FesersoftCommented:
If you load the Original Assembly into a different AppDomain, you can destroy the Appdomain and the Assembliesw will be released and can be removed or refreshed from the internet.
0
 
ArielLaubAuthor Commented:
You are probably right, but I still need a second program to do this. a program cannot unload itself and then reload it...
0
 
Tim_MusschootCommented:
Hello,

Try to copy the new DLL's over the old versions.  It works fine for me...

Regards,
Tim
0
All Courses

From novice to tech pro — start learning today.