安装Windows服务在Visual Studio中创建 [英] Install Windows Service created in Visual Studio
问题描述
当我在Visual Studio 2010中创建一个新的Windows服务,我得到的消息,说明使用InstallUtil并网开始运行服务。
When I create a new Windows Service in Visual Studio 2010, I get the message stating to use InstallUtil and net start to run the service.
我曾尝试步骤如下:
- 创建新的项目文件 - >新建 - >项目 - > Windows服务
- 项目名称:TestService的
- 建设项目作为为(服务1构造的OnStart,调用OnStop)
- 开启命令提示符下运行的C:\\ \\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exeTestService.exe
- 运行的网络启动TestService的
- Create new project File -> New -> Project -> Windows Service
- Project Name: TestService
- Build project as is (Service1 constructor, OnStart, OnStop)
- Open command prompt, run "C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" TestService.exe
- Run net start TestService.
步骤输出4
运行事务处理安装。
开始安装的安装阶段。
请参阅
C日志文件的内容:\Users\myusername\Documents\Visual工作室
2010\Projects\TestService\TestService\obj\x86\ 。Debug\TestService.exe
装配的进步。
See the contents of the log file for the C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe assembly's progress.
该文件位于C:\Users\myusername\Documents\Visual工作室
2010\Projects\Tes
tService\TestService\obj\x86\Debug\TestService.InstallLog。
The file is located at C:\Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\obj\x86\Debug\TestService.InstallLog.
安装程序集 C:\Users\myusername\Documents\Visual工作室
2010\Projects\TestS ervice\TestService\obj\x86\Debug\TestService.exe
Installing assembly 'C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\obj\x86\Debug\TestService.exe'.
受影响的参数是:
logtoconsole =
logtoconsole =
日志文件= C :\Users\myusername\Documents\Visual工作室
2010\Projects\TestService\T
estService\obj\x86\Debug\TestService.InstallLog
logfile = C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestService\T estService\obj\x86\Debug\TestService.InstallLog
assemblypath = C:\Users\myusername\Documents\Visual工作室
2010\Projects\TestServ ice\TestService\obj\x86 \Debug\TestService.exe
assemblypath = C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestServ ice\TestService\obj\x86\Debug\TestService.exe
与RunInstallerAttribute.Yes没有公共属性安装
可以在C中发现:\Users\myusername\\ \\Documents\Visual工作室
2010\Projects\TestService\TestSe rvice\obj\x86\Debug\TestService.exe
组装。
No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestSe rvice\obj\x86\Debug\TestService.exe assembly.
安装阶段顺利完成,并提交阶段为
开头。
The Install phase completed successfully, and the Commit phase is beginning.
查看日志文件的内容为
C:\Users\myusername\Documents\Visual工作室
2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe
总成的进步
See the contents of the log file for the C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe assembly's progress.
该文件位于C:\Users\myusername\Documents\Visual工作室
2010\Projects\Tes $ b $ ; b tService\TestService\obj\x86\Debug\TestService.InstallLog
The file is located at C:\Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\obj\x86\Debug\TestService.InstallLog.
犯下程序集C:\Users\myusername\Documents\\ \\Visual工作室
2010\Projects\TestS ervice\TestService\obj\x86\Debug\TestService.exe。
Committing assembly 'C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\obj\x86\Debug\TestService.exe'.
受影响参数是:
logtoconsole =
logtoconsole =
日志文件= C:\Users\myusername\Documents\ Visual Studio的
2010\Projects\TestService\T
estService\obj\x86\Debug\TestService.InstallLog
logfile = C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestService\T estService\obj\x86\Debug\TestService.InstallLog
assemblypath = C:\Users\myusername\Documents\Visual工作室
2010\Projects\TestServ ice\TestService\obj\x86\Debug\TestService.exe
assemblypath = C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestServ ice\TestService\obj\x86\Debug\TestService.exe
与RunInstallerAttribute.Yes没有公共属性安装
可以在C中发现:\Users\myusername\Documents\Visual工作室
2010\\ \\Projects\TestService\TestSe rvice\obj\x86\Debug\TestService.exe
组装。
No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestSe rvice\obj\x86\Debug\TestService.exe assembly.
删除文件InstallState因为有没有安装。
Remove InstallState file because there are no installers.
提交阶段已成功完成。
成交安装已完成。
第5步输出
服务名称是无效的。
更多的帮助可通过键入NET HELPMSG 2185。
More help is available by typing NET HELPMSG 2185.
推荐答案
你需要打开设计器中的文件Service.cs,右键单击它并选择菜单选项添加安装程序。
You need to open the Service.cs file in the designer, right click it and choose the menu-option "Add Installer".
它不会安装右出的,包装盒......你需要首先创建安装程序类
It won't install right out of the box... you need to create the installer class first.
在服务安装一些参考:
很老......但是这就是我所说的:
Quite old... but this is what I am talking about:
<一个HREF =http://arcanecode.com/2007/05/23/windows-services-in-c-adding-the-installer-part-3/> Windows服务在C#中:添加安装程序(第三部分)
这样,一个 ProjectInstaller.cs
将automaticaly创建。然后,你可以双击此,输入设计,并配置组件:
By doing this, a ProjectInstaller.cs
will be automaticaly created. Then you can double click this, enter the designer, and configure the components:
-
serviceInstaller1
的服务本身的属性:说明
,显示名称
,服务名称
和StartType
是最重要的。
serviceInstaller1
has the properties of the service itself:Description
,DisplayName
,ServiceName
andStartType
are the most important.
serviceProcessInstaller1
拥有这个重要的属性:帐户
全髋关节置换是至极帐户运行服务
serviceProcessInstaller1
has this important property: Account
thas is the account in wich the service will run.
例如:
this.serviceProcessInstaller1.Account = ServiceAccount.LocalSystem;
这篇关于安装Windows服务在Visual Studio中创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!