与安装项目一起安装时,Windows 服务未显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1359339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows Service not showing up when installed with Setup project
提问by Dan Bailiff
I have a simple windows Service developed in VS.net 2008 and VB.net. When I install the service using Installutil.exe from the command prompt it is working like a charm.
我有一个在 VS.net 2008 和 VB.net 中开发的简单 Windows 服务。当我从命令提示符使用 Installutil.exe 安装服务时,它就像一个魅力。
When I try to add a setup project and set the output and build and install it though it says successfully installed, it is not showing up in the services.
当我尝试添加安装项目并设置输出并构建并安装它时,尽管它说已成功安装,但它没有显示在服务中。
The event log shows that it is successfully installed. I just did check the registry, it did place the assemblies in HKEY_CURRENT_USER\Software\Microsoft\installer\assemblies.
事件日志显示它已成功安装。我只是检查了注册表,它确实将程序集放在了 HKEY_CURRENT_USER\Software\Microsoft\installer\assemblies 中。
But I don't understand why it is not showing up in the services listing. I refreshed and restarted.
但我不明白为什么它没有出现在服务列表中。我刷新并重新启动。
Any thoughts??
有什么想法吗??
Thanks
谢谢
采纳答案by AJ.
A couple of ideas:
几个想法:
Are you installing under the same Windows account that you are attempting to run it under? Do you have the Setup Project's "InstallAllUsers" property set to True?
您是否在尝试运行它的同一个 Windows 帐户下安装?您是否将安装项目的“InstallAllUsers”属性设置为 True?
Are you sure that you have the ProductName and Title properties in the Setup Project set correctly? Maybe the service is showing up in the list under a different name, i.e., "SetupProject1" or something.
您确定安装项目中的 ProductName 和 Title 属性设置正确吗?也许该服务以不同的名称出现在列表中,即“SetupProject1”或其他名称。
Similarily, in your service's ProjectInstaller class, in design view, look at the properties of the ServiceInstaller and make sure the ServiceName and DisplayName properties are set to what you want.
同样,在您的服务的 ProjectInstaller 类中,在设计视图中,查看 ServiceInstaller 的属性并确保 ServiceName 和 DisplayName 属性设置为您想要的。
回答by
Found solution You have to add a custom action in your MSI project. So in custom actions, add the output of your service to the Install section. This will then run the required installation code for your service. i.e. the same as what the installutil.exe does
找到解决方案 您必须在 MSI 项目中添加自定义操作。因此,在自定义操作中,将服务的输出添加到安装部分。然后,这将为您的服务运行所需的安装代码。即与 installutil.exe 的作用相同
Thanks for all the help
感谢所有的帮助
回答by Dan Bailiff
I had the same problem and didn't pay attention to the portion BEFORE creating the Setup project. http://msdn.microsoft.com/en-us/library/zt39148a(v=VS.100).aspx
我有同样的问题,没有注意创建安装项目之前的部分。 http://msdn.microsoft.com/en-us/library/zt39148a(v=VS.100).aspx
To create the installers for your service
为您的服务创建安装程序
In Solution Explorer, right-click Service1.vb or Service1.cs and select View Designer.
在解决方案资源管理器中,右键单击 Service1.vb 或 Service1.cs 并选择视图设计器。
Click the background of the designer to select the service itself, instead of any of its contents.
单击设计器的背景以选择服务本身,而不是其任何内容。
With the designer in focus, right-click, and then click Add Installer.
以设计器为焦点,右键单击,然后单击“添加安装程序”。
By default, a component class that contains two installers is added to your project. The component is named ProjectInstaller, and the installers it contains are the installer for your service and the installer for the service's associated process.
默认情况下,包含两个安装程序的组件类会添加到您的项目中。该组件名为 ProjectInstaller,它包含的安装程序是您的服务的安装程序和服务相关进程的安装程序。
In Design view for ProjectInstaller, click ServiceInstaller1 or serviceInstaller1.
在 ProjectInstaller 的设计视图中,单击 ServiceInstaller1 或 serviceInstaller1。
In the Properties window, make sure the ServiceName property is set to MyNewService.
在“属性”窗口中,确保将 ServiceName 属性设置为 MyNewService。
Set the StartType property to Automatic.
将 StartType 属性设置为自动。
In the designer, click ServiceProcessInstaller1 (for a Visual Basic project), or serviceProcessInstaller1 (for a Visual C# project). Set the Account property to LocalSystem. This will cause the service to be installed and to run on a local service account.
在设计器中,单击 ServiceProcessInstaller1(对于 Visual Basic 项目)或 serviceProcessInstaller1(对于 Visual C# 项目)。将帐户属性设置为本地系统。这将导致安装服务并在本地服务帐户上运行。