.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:\dir\xxx.exe

3、目录

当前目录为C:\Windows\System32\

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

4、错误排查

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

posted @ 2021-08-07 00:21  陈惊蛰  阅读(96)  评论(0编辑  收藏  举报