Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want my C# Windows Service to automatically update itself

Is there a framework that can be used to enable a C# Windows Service to automatically check for a newer version and upgrade itself? I can certainly write code to accomplish this, but I am looking for a framework that has already been implemented and (most importantly) tested.

[edit] Here is a link to a similar question with links to modern projects that help accomplish this: Auto-update library for .NET?

like image 211
Larry Smithmier Avatar asked Sep 20 '08 01:09

Larry Smithmier


2 Answers

The only way to unload types is to destroy the appdomain. To do this would require separation of your hosting layer from your executing service code - this is pretty complex. (sort of like doing keyhole surgery)

May be easier to either a) run a batch task or b) in-service detect updates then launch a seperate process that stops the service, updates assemblies etc. then restarts it.

If you're interested in the former, the MSDN patterns and practices folk wrote an app updater block that you adapt to your service.

https://web.archive.org/web/20080506103749/http://msdn.microsoft.com/en-us/library/ms978574.aspx

like image 87
stephbu Avatar answered Sep 21 '22 09:09

stephbu


I've had good experiences with Google Omaha for updating Windows Services. It can generally be used to update any Windows application but there is a tutorial for using it to update a Windows Service.

In comparison to other update frameworks, Omaha is more complex, but also the most powerful. This is because Google (and now also Microsoft) use it to update their browsers on billions of PCs. However, once it's set up and you understand the basics, it is a very nice experience.

like image 25
Michael Herrmann Avatar answered Sep 22 '22 09:09

Michael Herrmann