编写自我更新Windows服务的最佳实践 [英] Best practice for writing a self-updating windows service

查看:73
本文介绍了编写自我更新Windows服务的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要创建一个具有自我更新能力的Windows服务.

We need to create a windows service that has the ability to self update.

想到了三个选择,

  1. 第二个服务,用于管理第一个服务的检索,卸载和安装.

  1. a second service that manages the retrieval, uninstallation and installation of the first service.

使用某些第三方框架(欢迎提出建议.我相信.NET支持Windows窗体应用程序的自动更新,但Windows服务不支持)

Use of some third party framework (suggestions welcome. I believe .NET supports automatic updating for windows forms apps, but not windows services)

使用插件模型,该服务仅仅是包含更新和运行逻辑的外壳,并且服务的业务逻辑包含在可以换出的DLL中.

Use of a plugin model, whereby the service is merely a shell containing the updating and running logic, and the business logic of the service is contained in a DLL that can be swapped out.

任何人都可以阐明解决该问题的方法吗?

Can anyone shed some light on the solution to this problem?

谢谢

推荐答案

只是我有一些想法.

1似乎有问题,因为您最终要处理要解决的情况,因为在某个时候更新程序将需要更新. 3听起来不错,但是如果交换掉"是指在运行时使用一些奇特的反射方式来加载dll,我不确定性能是否会成为问题.

1 seems problematic because you end up dealing with the situation you're trying to resolve because at some point the updater will need updating. 3 sounds good but if by "swapped out" you mean using some fancy reflection to load the dll during run time I'm not sure if performance will become an issue.

还有第四个选项,服务可以生成更新过程,如果需要的话,该过程将允许它在运行更新程序之前对其进行更新.从那里开始,只需编写一个安装应用程序,该服务就会在关闭之前就生成.

There is a fourth option where the service can spawn an update process which would allow it to update the update executable if necessary before running it. From there it's a simple matter of writing an installation app which the service will spawn just before shutting down.

这篇关于编写自我更新Windows服务的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆