Windows服务错误 [英] Windows services Error

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

问题描述

我创建Windows服务&事件登录到我的项目中.但是不能立即在下面的代码下运行:

I create windows services & Event log in my project.But not run shortly below code:

Dim ServicesToRun() As System.ServiceProcess.ServiceBase
ServicesToRun = New System.ServiceProcess.ServiceBase() {New NotificationService()}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)


NotificationService是一个构造函数.
msg显示为无法从命令行或调试器启动服务.首先要安装Windows服务(使用installutil.exe),然后从ServerExplorer,Windows Services管理工具或NET START命令开始''


NotificationService is a constructor.
And msg is shown ''Cannot start service from command line or debugger. A Windows service mest first be install(using installutil.exe) and then start with the ServerExplorer, Windows Services Administrative tool or the NET START command''

推荐答案

完全按照消息告诉您的内容进行操作.您试图以交互方式运行旨在仅由系统服务主机托管的应用程序.您确实需要安装它并使用服务小程序运行.使用"Services.msc".

如果要使用InstallUtil.exe安装:它与需要实现的System.Configuration.Install命名空间中的类结合使用.
参见:
http://msdn.microsoft.com/en-us/library/50614e95%28v = VS.100%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.configuration. install.aspx [^ ].

您将需要提供ServiceProcessInstallerServiceInstaller的实现,请参见:
http://msdn.microsoft.com/en-us/library/system.serviceprocess. serviceinstaller.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.serviceprocess. serviceprocessinstaller.aspx [ ^ ].

这些只是指向您将需要使用的API的链接.您将需要彻底学习这些技术,因为它们不是很简单并且有些违反直觉. MSDN是您的朋友.

—SA
You need to do exactly what the message tells you. You are trying to run interactively the application designed to run hosted by the system service host only. You really need to install it and run using Services applet; use "Services.msc".

If you want to install with InstallUtil.exe: it works in conjunction with classes in the System.Configuration.Install namespace which you will need to implement.
See:
http://msdn.microsoft.com/en-us/library/50614e95%28v=VS.100%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.configuration.install.aspx[^].

You will need to provide implementation of ServiceProcessInstaller and ServiceInstaller, see:
http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.aspx[^],
http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceprocessinstaller.aspx[^].

These are just links to the API you will need to get into it. You will need to learn these techniques thoroughly as they are not very simple and somewhat counter-intuitive. MSDN is your friend.

—SA


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

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