简体   繁体   English

Visual Studio 2017的Windows服务模板

[英]Windows Service Template for Visual Studio 2017

The Windows Service Template no longer displays by-default for new projects in Visual Studio 2017....and the installer has no 'search' capability. 对于Visual Studio 2017中的新项目,Windows服务模板不再默认显示....并且安装程序没有“搜索”功能。

All this AZURE stuff is great, but I still gotta do normal 'on-prem' work too...and I hate maintaining 2 versions of Visual Studio. 所有这些AZURE的东西都很棒,但我仍然需要做正常的“本地”工作......而且我讨厌维护2个版本的Visual Studio。

Any thoughts here? 这有什么想法?

在此输入图像描述

在此输入图像描述

Just checked here. 刚看过这里。 I see project "Windows Service (.NET Framework)" under the Windows Classic Desktop folder under Visual C#. 我在Visual C#下的Windows Classic Desktop文件夹下看到了“Windows Service(.NET Framework)”项目。

(Visual Basic has a similar entry.) (Visual Basic有类似的条目。)

Only some templates are shown in parent folders, for more specialist templates you need to be more specific. 父文件夹中只显示一些模板,对于更多专业模板,您需要更具体。

But also the search finds both. 但搜索也找到了。

NB I selected ".NET Desktop" workload on install, which I see you have not. NB我在安装时选择了“.NET桌面”工作负载,我发现你没有。

在此输入图像描述

VS2017 --> New project --> Visual Basic or Visual C# --> Windows Classic Desktop --> Windows Service VS2017 - >新项目 - > Visual Basic或Visual C# - > Windows经典桌面 - > Windows服务

Check the .NET desktop development option in the installer, then click Modify. 检查安装程序中的.NET桌面开发选项,然后单击“修改”。

Visual Studio 2017安装程序

Also check out this recent post (currently dated 2017-3-30) from MS to do it without the project template: 另请查看MS最近的帖子(目前日期为2017-3-30),无需项目模板:

How to: Write Services Programmatically 如何:以编程方式编写服务

The key points are as follows: 关键点如下:

  • Create a new project 创建一个新项目
  • Add "System.dll" and "System.ServiceProcess.dll" as References 添加“System.dll”和“System.ServiceProcess.dll”作为参考
  • Create a class inheriting from ServiceBase and create a Program.cs with Main exactly like the template project does 创建一个继承自ServiceBase的类,并使用Main创建一个与模板项目完全相同的Program.cs

If you are talking Windows Template Studio Universal then You have to install the extension in Visual Studio. 如果您正在谈论Windows Template Studio Universal,则必须在Visual Studio中安装扩展。

Go to Tools menu >> Extensions & Updates >> Online >>then search for Windows Template Studio 转到工具菜单>>扩展和更新>>在线>>然后搜索Windows模板Studio

OR go to https://marketplace.visualstudio.com/items?itemName=WASTeamAccount.WindowsTemplateStudio#overview 或者转到https://marketplace.visualstudio.com/items?itemName=WASTeamAccount.WindowsTemplateStudio#overview

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM