Visual Studio 缺少“添加安装程序” 服务项目中的链接
我正在构建一个 Windows 服务并遵循这篇 MSDN 文章,但我被困在“创建安装程序”下的第 3 步。 我找不到它所指的“添加安装程序”链接。 我已经点击了所有地方,包括完全按照它给出的说明进行操作,但我似乎找不到它。 Google 上的一些人也遇到了同样的问题,但从未找到解决方案(除了添加 ServiceInstaller 对象并手动配置它)。
还有其他人遇到过这个问题并找到原因吗? 我正在使用 VS2008,如果重要的话,目标是 .Net 2.0。
I'm building a Windows service and following this MSDN article, but I'm stuck on step 3 under "Create an installer". I can't find the "Add Installer" link it's referring to. I've clicked everywhere, including following the instructions it gives exactly, but I can't seem to find it. A few people on Google have had the same problem, but never found a solution (other than adding the ServiceInstaller object and configuring it manually).
Has anybody else had this problem and found a reason? I'm using VS2008 and targeting .Net 2.0 if it matters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于 Visual Studio 2012,右键单击“Services1.cs”并选择“视图设计器”(或按 Shift-F7)。 然后,右键单击设计器的灰色背景。
然后,也只有到那时,您才会看到微软一直向您隐藏的复活节彩蛋:难以捉摸的
添加安装程序
链接。For Visual Studio 2012, right click on "Services1.cs" and select "View Designer" (or press Shift-F7). Then, right click on the grey background of the designer.
Then, and only then, will you see the Easter Egg that Microsoft has been hiding from you all this time: the elusive
Add Installer
link.检查您尝试添加安装程序的 .cs 文件是否扩展了
System.ServiceProcess.ServiceBase
而不是System.ComponentModel.Component
。要将 .cs 文件作为代码而不是在设计器中打开,请在解决方案资源管理器中选择它并按 F7 或右键单击它并选择“查看代码”。
Check that the .cs file where you're trying to add the installer extends
System.ServiceProcess.ServiceBase
and notSystem.ComponentModel.Component
.To open the .cs file as code and not in the designer, select it in the Solution Explorer and press F7 or right click it and select "View Code".
他们所说的“灰色区域”是“属性”面板的“属性”中的“命令”面板(不是拼写错误)。 它不是很有用,所以你可能已经把它关掉了,我就是这么做的。
您可以通过右键单击“属性”面板并选择“命令”来重新启用它,或者通过右键单击服务设计视图(带有“将组件添加到您的类...”的大棕褐色窗口)直接添加安装程序项目。 ”)并选择“添加安装程序”。
The "Gray area" they're talking about is the Commands panel from Properties of the Properties panel (not a typo). It is not very useful so you have probably shut it off, I did.
You can either re-enable it by right-clicking the Properties panel and selecting "Commands", or add an Installer project directly by right-clicking the Service design view (the big tan window with "To add components to your class...") and selecting "Add Installer".
要更新新的 Visual Studio Express(2015) 版本:
看来我们无法从 Express 版本中获得此“添加安装程序”。 但这确实很简单。 您只需创建一个类并添加以下代码即可。
您还需要添加引用 System.Configuration.Install.dll。
To get up to date with the new visual studio express(2015) version:
It seems that we cannot have this "Add Installer" from the express edition. But it's quite simple really. You simply need to create a class and add the below code.
Also you need to add the reference System.Configuration.Install.dll.