Son*_*oul 20 c# windows-services
我正在尝试安装Windows服务.
运行c:\ windows\microsoft.net\Framework64\v4.0.30319\InstallUtil.exe c:\ foo\MyAssembly.exe
我得到一个很好的消息,所有阶段(安装,提交)成功完成.
(我不会被提示输入服务凭据)
之后我没有在服务控制台中看到该服务.在安装日志中没什么用处.
该解决方案建立在64位盒子上,我试图在64位机器上安装该服务.但是,我没有看到64位作为解决方案属性的选项.我手动编辑了所有csproj文件,为[platform]节点选择"x64".
我可以运行视觉工作室服务没问题.
installer.cs
[RunInstaller(true)]
public partial class Installer : System.Configuration.Install.Installer
{
public Installer() {
InitializeComponent();
}
}
Run Code Online (Sandbox Code Playgroud)
这是visual studio提供的默认安装程序.
Mik*_*ray 28
您需要将一些Installer对象添加到Installers集合中.这里的示例是您要安装Windows服务的示例.就像是
[RunInstaller(true)]
public class Installer : System.Configuration.Install.Installer
{
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
public Installer()
{
// Instantiate installers for process and services.
processInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();
// The services run under the system account.
processInstaller.Account = ServiceAccount.LocalSystem;
// The services are started manually.
serviceInstaller.StartType = ServiceStartMode.Manual;
// ServiceName must equal those on ServiceBase derived classes.
serviceInstaller.ServiceName = "Hello-World Service 1";
// Add installers to collection. Order is not important.
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16464 次 |
| 最近记录: |