我正在尝试安装windows服务。
运行c:\windows\microsoft.net\Framework64\v4.0.30319\InstallUtil.exe c:\foo\MyAssembly.exe
我得到了一条很好的消息,所有阶段(安装、提交)都成功完成。
(系统未提示我输入服务凭据)
之后,我在服务控制台中看不到该服务。安装日志中没有任何有用的信息。
该解决方案构建在64位机器上,我正在尝试将该服务安装在64位机器上。但是,我不认为64位是解决方案属性中的一个选项。我手动编辑了所有的csproj文件,为平台节点选择了"x64“。
我可以在visual studio之外运行该服务,没有问题。
installer.cs
[RunInstaller(true)]
public partial class Installer : System.Configuration.Install.Installer
{
public Installer() {
InitializeComponent();
}
}
这是visual studio提供的默认安装程序。
发布于 2012-09-11 12:09:19
您需要向Installers集合添加一些Installer对象。示例here就是您安装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);
}
}
发布于 2017-01-23 02:12:48
下面的SO问题有类似的场景和答案,可能也与来自Google搜索链接的人相关。
https://stackoverflow.com/questions/12362455
复制相似问题