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

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...

0
ArielLaub
Asked:
ArielLaub
1 Solution
 
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
 
CoolAssCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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