I'm developing a .NET4-based application in C# which runs as a windows service.
I'd like this application to be able to upgrade itself when instructed to do so by a web-service that it connects to periodically. Is there an accepted way to accomplish this? Is it even possible?
The way I'm thinking of it is something like this:
Would this work? You may detect from my terminology and approach that I'm from a UNIX background and not a windows background. I've made this approach work on UNIX, but I have no idea what sort of windows gotchas may exist...
UPDATE: My main motivation for this question is around the technical feasibility of a self-updating .NET application (how to do an in-place replacement of .DLLs, etc). As pointed out in the comments, there are a host of other considerations involved in implementing a feature like this, in particular security concerns around verifying the new software components being applied are in fact legitimate. These are also important, but not specific to .NET or Windows (imo). Comments on these areas are welcome of course, but they are not my primary concern at this time...
Your approach is certainly reasonable, but unless you run under the LocalSystem account (not recommended!) you don't have permissions to write to your application folder or to start/stop your own service. Even if you run under the user's account, you might have problems because of UAC although I am not sure of this. Anyway running under the user's account is not good since it requires the user to enter the account password and has additional complications arising from password change, lockout etc. You will have to set ACLs on both from your installer, which will have to run elevated anyway to install a service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With