installutil成功完成但未安装服务

我正在尝试安装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(); } } 

这是visual studio提供的默认安装程序。

您需要将一些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); } } 

以下SO问题具有类似的场景和答案,这些场景和答案也可能与来自Google搜索链接的人员相关。

安装在Visual Studio中创建的Windows服务