Windows服务创建中的问题 [英] Problem in creation of windows services

查看:338
本文介绍了Windows服务创建中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,
我是新手,请帮助我.
我必须创建一个Windows服务,``onstart''我必须重新启动sql server 2005,``onstop''什么也没做.我的``重新启动sql server''代码可以正常工作.但是直到现在我还不能提供窗户服务.我使用过演练:在组件设计器中创建Windows Service应用程序 [ ^ ].但是它仍然无法正常工作.我也使用MSDN中的代码,但无法正常工作.我的老板骂我.我最近参加了这份工作.出现错误消息后,我得到when-
1.当我从服务"手动启动我的服务时,它显示以下消息:本地计算机上的MyNS服务已启动,然后停止了".如果某些服务没有任何工作,它们会自动停止,例如,性能日志和警报"服务.

2.当我双击MyNS.exe时(C:\ Documents and Settings \ Pragati \ My Documents \ Visual Studio 2005 \ Projects \ MyNS \ MyNS \ bin \ Release \ MyNS.exe).它显示无法从命令行或调试器启动服务.必须首先安装Windows Service(使用installutil.exe),然后使用ServerExplorer,Windows Services Administrativ工具或NET START命令启动."
我很担心请帮帮我.
Pintu Verma
[已删除电子邮件ID]

Dear Sir,
I am a novice progammer .Please help me.
I have to create a windows service , ''onstart'' i have to restart sql server 2005 and ''onstop'' does nothing.My ''restart the sql server'' code working ok. But till now i can not make my window service. I have used Walkthrough: Creating a Windows Service Application in the Component Designer[^]. But it is not still working. I have ditto use the code from MSDN but it is not working. My Boss scolds me. I have join this job recently. Following error message , i get when-
1. when i start my service manually from Services it displays the message: The MyNS service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service.

2. When i double click on my MyNS.exe (C:\Documents and Settings\Pragati\My Documents\Visual Studio 2005\Projects\MyNS\MyNS\bin\Release\MyNS.exe) . It display the "Cannot start service from the command line or a debugger. A Windows Service must first be installed(using installutil.exe) and then started with the ServerExplorer,Windows Services Administrativ tool or the NET START command."
I am so worried about it. Please help me.
Pintu Verma
[email-id removed]

推荐答案

重要说明:您无需显示电子邮件ID.您可以在此处提交答案,因此没有人会向您发送答案.此外,您这样做是在邀请垃圾邮件发送者.所以下次要小心.

现在回答您的问题.我将从第2点开始.

2.您需要将安装程序添加到Windows服务.然后,您可以使用命令提示符安装它或创建一个安装项目.快速的Google搜索可以为您
Important Note: You do not need to display your email-id. There is an option of submitting answer here so no one is going to mail you the answer. Moreover you are inviting SPAMMERS by doing this. So be careful next time.

Now answer to your question. I will start with point 2.

2. You need to add installer to your Windows Service. Then you can install it using command prompt or create a setup project. A quick Google Search would have given you this[^].

1. This error can only come when you have installed the service. It means the service has nothing to do and is idle and in such cases the service stops automatically after it is started.
You said you are just starting the SQL Server OnStart of the service. This can be done using some script or a console program as well. why do you need a service? Anyways the service will start the Server and then gets stopped. So your purpose is solved.


这篇关于Windows服务创建中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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