.netcore写windows服务几个注意点

1、引入

包:Microsoft.Extensions.Hosting.WindowsServices

参考:https://devblogs.microsoft.com/ifdef-windows/creating-a-windows-service-with-c-net5/

代码:UseWindowsService

2、安装

sc create XXXService BinPath=E:dirxxx.exe

3、目录

当前目录为C:WindowsSystem32

需通过注册表或其他途径获取程序运行目录

4、错误排查

进入控制面板-管理工具-事件查看器

原文地址:https://www.cnblogs.com/pasoraku/p/15110821.html