1.新建.Net Core控制台程序,添加新建项Windows服务: 修改Progran.cs:class Program{static void Main(string[] args){ServiceBase[] services = new ServiceBase[] { new WinService() };ServiceBase.Run(servic...
1.新建.Net Core控制台程序,添加新建项Windows服务:

修改Progran.cs:
class Program
{
static void Main(string[] args)
{
ServiceBase[] services = new ServiceBase[] { new WinService() };
ServiceBase.Run(services);
}
}
发布设置部署模式为 独立:

发布后文件里会有一个exe文件:

我们需要使用命令来将其创建为Windows服务:
sc create MyWinService binpath="***.exe"
停止服务:
sc stop MyService
卸载服务:
sc delete MyService


沃梦达教程
本文标题为:.Net Core快速创建Windows服务
基础教程推荐
猜你喜欢
- C#实现归并排序 2023-05-31
- C#使用NPOI将excel导入到list的方法 2023-05-22
- 如何用C#创建用户自定义异常浅析 2023-04-21
- 浅谈C# 构造方法(函数) 2023-03-03
- Unity虚拟摇杆的实现方法 2023-02-16
- C#执行EXE文件与输出消息的提取操作 2023-04-14
- C# TreeView从数据库绑定数据的示例 2023-04-09
- C#使用SQL DataAdapter数据适配代码实例 2023-01-06
- C#中参数的传递方式详解 2023-06-27
- C#使用Chart绘制曲线 2023-05-22
