C# 缺少 Windows 服务模板?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9881270/
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 template missing?
提问by Ryan S.
When I go to create a new project, the "Windows Service" template isn't there!
当我去创建一个新项目时,“Windows 服务”模板不存在!
Can someone please either tell me where I can get it, or provide a download link to it?
有人可以告诉我在哪里可以得到它,或者提供它的下载链接吗?
采纳答案by SimperT
In Visual Studio 2015 I could not find the Windows Service template by selecting anything in left pane. Including c# -> Windows. However, when I query 'Windows Service' in the search bar at the top right corner, voilà, templates for c# or VB show up.
在 Visual Studio 2015 中,我无法通过在左窗格中选择任何内容来找到 Windows 服务模板。包括 c# -> Windows。但是,当我在右上角的搜索栏中查询“Windows 服务”时,瞧,c# 或 VB 的模板出现了。
回答by Curiosity
For Visual Studio 2010 (10.0):
对于Visual Studio 2010 (10.0):
You can navigate to your Visual Studio install directory and run devenv /installvstemplatesas admin
您可以导航到 Visual Studio 安装目录并devenv /installvstemplates以管理员身份运行
OR
或者
You can follow the documentation on how to create a windows service without the templatehere
您可以按照有关如何在此处创建没有模板的 Windows 服务的文档进行操作
OR
或者
You can perform the steps below to reset your Visual Studio templates:
您可以执行以下步骤来重置您的 Visual Studio 模板:
Please open
Windows Explorer, and navigate to<Visual Studio Installation Path>\Common7\IDE(by default is C:\Program Files \Microsoft Visual Studio 10.0\Common7\IDE);Delete the
ItemTemplatesCache,ProjectTemplatesCachefolder;Open
Visual Studio Command Prompt (2010)under Start menu -> All Programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools (run it with Administrator privilege: right-click the program -> Run as administrator);Run the
vbexpress /InstallVSTemplatesswitchRun the
vbexpress /Setupswitch
请打开
Windows Explorer,并导航到<Visual Studio Installation Path>\Common7\IDE(默认为 C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE);删除
ItemTemplatesCache,ProjectTemplatesCache文件夹;打开
Visual Studio Command Prompt (2010)下开始菜单- >所有程序- >微软的Visual Studio的2010 - > Visual Studio工具(以管理员权限运行:右键单击程序- >运行方式管理员);运行
vbexpress /InstallVSTemplates开关运行
vbexpress /Setup开关
OR
或者
you can download template here.But oroblem is it is in vb.someone can convert it to c#.
你可以在这里下载模板。但oroblem是在vb中。有人可以将它转换为c#。
回答by Jürgen Steinblock
This is not a direct solution to your problem but you should have a look at Topshelfwhich allows you to create an application that can run as a console app and also install/uninstall itself as a service. I have used it several times and it is much easier to use than a traditional windows service with .Net
这不是您问题的直接解决方案,但您应该查看Topshelf,它允许您创建一个应用程序,该应用程序可以作为控制台应用程序运行,也可以作为服务安装/卸载自身。我已经用过好几次了,它比使用 .Net 的传统 Windows 服务更容易使用
回答by Dung
It it a bad documentation of Microsoft that causes confusion to many including me. Here is how: in the New Project you will need to DRILL DOWN by selecting Templates->Visual C#-> Windows Desktop (click on it!) then you will find "windows service" template on the right. see attachment.
它是微软的一个糟糕的文档,导致包括我在内的许多人感到困惑。方法如下:在新项目中,您需要通过选择模板-> Visual C#-> Windows 桌面(单击它!)向下钻取,然后您将在右侧找到“windows 服务”模板。详见附件。
I hope it helps.
我希望它有帮助。
Dunn.
邓恩。
回答by user3188978
In addition to @SimperT 's answer: The same is the case with Visual Studio 2013 Just query Windows Service in the Top right search box and templates for Windows Service in VB and C# are displayed.
除了@SimperT 的回答:Visual Studio 2013 也是如此,只需在右上角的搜索框中查询 Windows 服务,就会显示 VB 和 C# 中的 Windows 服务模板。
Hope it helped :)
希望它有所帮助:)


回答by ceoctr
For Visual Studio 2015 (14.0):
对于 Visual Studio 2015 (14.0):
Navigate to C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplates\CSharp\General\1033\Serviceand click Service.
导航到C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplates\CSharp\General\1033\Service并单击服务。
回答by cmartin
File > New > Project > Templates > Visual C# > Windows > Classic Desktop > Windows Service
文件 > 新建 > 项目 > 模板 > Visual C# > Windows > 经典桌面 > Windows 服务
The confusion is because Microsoft's own walkthrough doesn't give the full path to the project template: https://msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx
混淆是因为微软自己的演练没有给出项目模板的完整路径:https: //msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx
回答by Mohamed Salah


Go to File > New > Project; Templates > Visual C# > Windows > Classic Desktop; select Windows Service.
转到文件>新建>项目;模板 > Visual C# > Windows > 经典桌面;选择 Windows 服务。

