在Visual Studio中添加服务安装程序和服务流程安装程序

问题描述:

由于某种原因,在将Installer类添加到Windows Service项目之后,我以设计模式打开它并单击鼠标右键,但是没有选择添加服务安装程序或服务进程安装程序的选项.有谁知道为什么会这样?

For some reason, after adding a Installer class to my Windows Service project, I open it up in design mode and right click, but there is no option to add either a service installer or a service process installer. Does anyone know why this may be the case?

在Visual Studio 2008和2010中,最好的方法是在设计模式下打开ServiceBase组件(默认命名为Service1). .然后,右键单击设计器,然后选择添加安装程序选项.这将添加ProjectInstaller组件以及必要的程序集引用.反过来,ProjectInstaller组件具有自动添加的服务安装程序和服务流程安装程序.

In both Visual Studio 2008 and 2010, the best way to do this is to open the ServiceBase component (named Service1 by default) in design mode. Then, right-click in the designer and select the Add Installer option. This adds a ProjectInstaller component along with the necessary assembly references. The ProjectInstaller component, in turn, has the service installer and service process installer added automatically.

在没有其他细节的情况下,我最好的猜测是您在项目中手动添加了一个组件/类并将其命名为Installer,而不是让Visual Studio为您完成工作.

Without additional detail, my best guess is that you manually added a component/class to your project and named it Installer instead of letting Visual Studio do the work for you.

请参阅我的帖子此处有关如何操作的信息在Visual Studio 2008中创建基本服务(似乎也可以在2010年工作).请特别注意步骤6.

See my post here for how to create a basic service in Visual Studio 2008 (seems to work in 2010 as well). Pay particular attention to Step 6.

希望这会有所帮助.