We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed last year.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(9)
卸载类型的唯一方法是销毁应用程序域。 要做到这一点需要将托管层与执行服务代码分离 - 这是相当复杂的。 (有点像做锁孔手术)
可能更容易a)运行批处理任务或b)服务中检测更新,然后启动一个单独的进程来停止服务,更新程序集等,然后重新启动它。
如果您对前者感兴趣,MSDN 模式和实践人员编写了一个应用程序更新程序块,您可以根据自己的服务进行调整。
https:// web.archive.org/web/20080506103749/http://msdn.microsoft.com/en-us/library/ms978574.aspx
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
我在使用 Google Omaha 更新 Windows 服务方面获得了良好的体验。 它通常可用于更新任何 Windows 应用程序,但有一个使用它的教程更新 Windows 服务。
与其他更新框架相比,Omaha 更复杂,但也是最强大的。 这是因为谷歌(现在还有微软)使用它来更新数十亿台电脑上的浏览器。 然而,一旦设置完毕并且您了解了基础知识,这将是一次非常好的体验。
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.
我不知道有任何框架可以促进解决这个特定问题。
您可以尝试将服务的业务逻辑与实际服务代码分离到不同的程序集中。 让服务程序集定期检查业务逻辑程序集的更新,如有必要,从远程源复制它,卸载旧的 BL 程序集(可能还删除),然后动态加载新版本(卸载旧程序集不是一项微不足道的任务)。
I'm not aware of any Frameworks that facilitate solutions to this specific problem.
What you could try though is separating the business logic of the service from the actual service code into different assemblies. Have the service assembly check for updates to the business logic assembly at regular intervals, copy it from a remote source if necessary, unload the old BL assembly (and perhaps delete), and then dynamically load the new version (unloading the old assembly is not a trivial task).
另一种可能的解决方案是运行一个单独的服务,如果有更新,则停止另一个服务,然后更新该服务。 您无法自行更新服务,因为正在运行的 .dll 不会停止。
分离业务逻辑层将是一个不错的选择。 您还可以重写主服务以在主服务或控制服务的反射下运行。 这类似于分离业务逻辑,只需要停止线程并重新启动它。
据我所知,没有已知的框架可以做到这一点。 我自己已经这样做了,但这不是一个公共框架。
Another possible solution is to have a seperate service that runs, stops the other one, if there is an update, and then updates the service. You can't have a service update itself because the .dll that is running will not stop.
Seperating the business logic layer would be a good option. You could also rewrite the main service to run under reflection by a master or control service. This is similar to seperating the business logic, and it would just require stopping a thread and the starting it again.
I know of no known framework that does this. I have done this myself, but that is not a public framework.
我一直在使用 WyBuild 来更新我的应用程序(包括 Windows 服务),它非常棒。 非常易于使用,并且非常容易与现有应用程序集成。 这是一个非常棒的自动更新框架...
http:// /wyday.com/wybuild/help/automatic-updates/windows-services-console-apps.php
http://wyday.com/wybuild/help/silent-update-windows -service.php
请注意,它是一个付费框架(许可证是每个开发人员的,包括免费试用)
I've been using WyBuild to update my applications (including Windows services) and it's pretty awesome. Really easy to use, and really easy to integrate with existing applications. It's a pretty great Automatic Updating framework...
http://wyday.com/wybuild/help/automatic-updates/windows-services-console-apps.php
http://wyday.com/wybuild/help/silent-update-windows-service.php
Note that it is a paid framework (the licence is per developer, a free trial is included)
如果其他人正在搜索此内容; 我发现这个链接很有趣。 我还没有实现这个解决方案,但看起来它可能对我有用
http://www.eggheadcafe.com/articles/20041204.asp" Eggheadcafe.com/articles/20041204.asp
In case anyone else is searching for this; I found this link interesting. I have not implemented this solution, but it looks like it might work for me
http://www.eggheadcafe.com/articles/20041204.asp
您可以使用 NetSparke,它支持 .NET Core 3+ (.NET 5+) 和 .NET Framework 4.5.2+。 它带有内置 UI 或根本没有任何 UI。 您可以自己处理所有事件。 它与 appcast.xml 一起使用(并且还有一个实用程序来生成它),独立于平台并且开箱即用。
只需阅读其存储库上的文档并检查示例应用程序即可;-)
You can use NetSparke, it supports .NET Core 3+ (.NET 5+) and .NET Framework 4.5.2+. It comes with built-in UI or without any UI at all. You can handle all the events by yourself. It works with an appcast.xml (and also have a utility to generate that), is platform independent and just works out of the box.
Just work trough the documentation on their repository and check the example app ;-)
正如其他人所建议的那样,我正在研究 NetSparkle 并遇到了这些替代方案。 由于易于使用和功能集,我选择 AutoUpdater.NET。
I was looking into NetSparkle as others have suggested and came across these alternatives. AutoUpdater.NET is my pick due to ease of use and feature set.
你能澄清一下你的问题吗? 我有点困惑 因为据我所知
您始终可以覆盖服务使用的 DLL。 服务的复制和重新启动可以轻松地成为构建过程的一部分。
Could you clarify your question a bit? I'm a bit confused, because as far as I know,
you can always overwrite the DLLs the service uses. The copy and restart of the service can easily be made part of you build process.