Is there a more graceful way of updating a .Net Windows Service other than using InstallUtil to uninstall and re-install? Note - I will be doing this programmatically.

有帮助吗?

解决方案

I succesfully experienced this:

  • Stop the service
  • Replace the old EXE, DLLs and stuff by the new one using a file copy
  • Restart the service

It works pretty well, unless your service name (or EXE filename) has changed: then you will have to uninstall it and reinstall it.

I do not use strong naming nor GAC features, and I do not know if restrictions applies in such a case.

其他提示

In general, I agree with Larry's answer, but you must check the specifics of your service installation process, since it may be more than just registering the service. For instance, if you are you are using the Installer(s) to install performance counters, WMI instruments, instrumentation manifests, set registry keys, setup Config files, etc., you'll need to account for these when updating the installed service as well.

You get all this for free using Windows Installer. The ServiceControl table has flags for starting and stopping the service during an install/upgrade. Basically once you've created your installer you just run it for upgrade and all is taken care of for you.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top