问题描述
我不知道为什么 Visual Studio 有上百万个不同的版本(Visual Studio for Desktop、Visual Studio for Web、Visual Studio Code 等)并且每个版本都有一组不同的项目模板.无论如何,我遇到的问题是我正在通过 Visual Studio Web 2013 创建一个 ASP.NET MVC 应用程序,我希望它得到在我的 App_Start() 中启动的 Windows 服务的支持.当然,问题是当我阅读 https://msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx 当我尝试向我的项目添加新项目时,Visual C# 上没有 Windows 服务模板解决方案.
I don't know why Visual Studio is such that there are a million different versions (Visual Studio for Desktop, Visual Studio for Web, Visual Studio Code, etc.) and each version has a different set of project templates. Anyhow, the problem I'm having is that I'm creating an ASP.NET MVC application through Visual Studio Web 2013 and I want it to be supported by a Windows Service that is started in my App_Start(). The problem of course is that when I read the instructions on https://msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx there is no Windows Service template on Visual C# when I try to add a new project to my solution.
推荐答案
我了解您的 Web 端点将依赖于 Windows 服务,并且您希望将该 Windows 服务作为解决方案的一部分进行创作.
I understand your web endpoint will be dependent on a Windows Servie, and you want to author that windows service as part of your solution.
暂且不说 VS.net 2015 社区版汇总了您需要的所有功能.您不需要专门的项目模板来创建 Windows 服务.它只是自动将一些引用和模板添加到您的项目中.VS .net 中的所有项目模板都依赖于 .net 框架 - 这在 VS.net 的一个安装和另一个安装之间没有任何区别.
Setting aside that VS.net 2015 Community Edition rolls up all the functionality you need. You dont need the project template specifically to create a windows service. It just automatically adds some references and templates into your project. All project templates in VS .net rely on the .net framework - and that isn't any different between one installation and another of VS.net.
在实践中,您可以在记事本中编写为 .net 编写的 Windows 服务,只需手动调用 CSC 编译器 - VS.net 版本只是增加了一些易用性.
In practise you can code a windows service written for .net in Notepad and just call the CSC compiler manually - the version of VS.net just adds some ease-of-use.
这里有一组说明 https://msdn.microsoft.com/en-us/library/9k985bc9(v=vs.110).aspx 来自 Microsoft,其中包含有关如何在没有模板的情况下制作 Windows 服务的具体说明.
There is a set of instructions here https://msdn.microsoft.com/en-us/library/9k985bc9(v=vs.110).aspx from Microsoft which include specific instructions on how to make a windows service without a template.
这篇关于我可以在 Visual Studio Web 2013 中创建 Windows 服务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!