转换一个控制台应用程序以服务? [英] Converting a Console Application to a service?

查看:140
本文介绍了转换一个控制台应用程序以服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找不同的方法与优势/劣势的转换,我们使用的是长期的控制台应用程序中一个窗口服务。我们使用一种叫做Java服务包装ActiveMQ的,我相信人告诉我,你可以用它换什么。这并不是说你应该用它虽然换东西;我们有我们的问题与此设置。

I'm looking for different ways with strengths/weaknesses for converting a console application we are using long term in to a windows service. We use something called java service wrapper for ActiveMQ, and I believe people have told me you can wrap anything with it. That's not saying that you should wrap anything with it though; we've had our issues with this setup.

控制台应用程序是在默认情况下记录了大量的控制台信息一个.NET控制台应用程序,尽管这是可配置的。

The console app is a .NET console application that by default logs a lot of info to the console, though this is configurable.

任何reccomendations?

Any reccomendations?

如果我们只是重建它在Visual Studio中作为一种服务?使用的包装?哪一个?

Should we just rebuild it in Visual Studio as a service? Use a wrapper? Which one?

推荐答案

我会很想创建一个空的Windows服务项目,只要抓住了处理服务的比特;这是不是很多 - 一些参考和一些code。在主要。实际上,你可以有你的现有的控制台工作的两个的作为服务的的作为控制台 - 无论是通过检查args设置为和使用(例如)-console开关,否则我相信你可以检查 Environment.UserInteractive

I would be tempted to create an empty windows service project, and just grab the bits that deal with a service; it isn't a lot - a few references and some of the code in Main. You can actually have your existing console work both as a service and as a console - either by checking the args to Main and using (for example) a "-console" switch, or I believe you can check Environment.UserInteractive.

如果它是在控制台模式下,运行code,因为你现在做的;如果是在服务模式,运行code您从模板项目抓起。

If it is in "console" mode, run your code as you do now; if it is in service mode, run the code you grabbed from the template project.

有关信息,你可以的的具有相同的EXE工作,安装/卸载程序的服务!我这样做有 - 安装/-uninstall开关。举一个例子,<一href="http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/browse%5Fthread/thread/4d45e9ea5471cba4">see这里。

For info, you can also have the same exe work as the installer/uninstaller for the service! I do this with "-install" / "-uninstall" switches. For an example, see here.

这篇关于转换一个控制台应用程序以服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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