如何将Visual Studio 2005控制台应用程序转换/创建到Windows服务? [英] How do I convert/create a Visual Studio 2005 Console application into a Windows Service?

查看:107
本文介绍了如何将Visual Studio 2005控制台应用程序转换/创建到Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是VS的新手,刚创建了我的第一个控制台应用程序(不是没有Hello World)哈哈。现在我需要它作为一项服务。它将运行在2003和2008 Windows服务器上。我可以在2005年使用一些转换过程,还是必须从头开始?提前谢谢!



Pertinent''s:



Visual Studio 2005 C#控制台应用程序。



程序寻找批处理文件并执行它们。还要在找到新的之前删除先前使用的那些。



我已尝试在计划任务下运行它,但似乎没有重复使用该方法。

Hi all, I am new to VS, and just created my first console application (no not Hello World) haha. Now I need it to be a service. It will run on 2003 and 2008 Windows servers. Is there some conversion process I can use in 2005 or will I have to start from scratch? Thank you in advance!

Pertinent''s:

Visual Studio 2005 C# Console Application.

The program seeks out batch files and executes them. Also deletes ones previously used before finding the new ones.

I''ve tried running it under scheduled tasks but it doesn''t seem to repeat using that method.

推荐答案

嗨Sandra,



在您的控制台应用程序中添加对System.ServiceProcess.ServiceBase的引用,并像这样实现您的类。



Hi Sandra,

Add a reference to System.ServiceProcess.ServiceBase to your console application and implement your class like this.

public class WinService1 : System.ServiceProcess.ServiceBase





完成以下链接中的步骤,以实现OnStart,OnStop和其他方法的代码。



http://www.c-sharpcorner .com / UploadFile / mahesh / window_service11262005045007AM / window_service.aspx [ ^ ] < br $>


快乐编码:)



问候,

Manoj



Follo the steps in the below link to implement code for OnStart, OnStop and other methods.

http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx[^]

Happy coding :)

Regards,
Manoj


看下面的文章; 简单Windows服务示例 [ ^ ]
Look at the following article; Simple Windows Service Sample[^]


这篇关于如何将Visual Studio 2005控制台应用程序转换/创建到Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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