I want my C# Windows Service to automatically update itself

后端 未结 6 1704
暖寄归人
暖寄归人 2020-12-09 08:13

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

6条回答
  •  一整个雨季
    2020-12-09 08:32

    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

提交回复
热议问题