appsettings.json启动.NET核心Windows服务时未读取
我关注Microsoft 指南。
从Visual Studio或命令行运行时,AppSettings.json
文件将被读取,但是当服务Manager执行服务DLL时,它会失败。
从配置中填充的所有变量保持空为空。
问题是Windows Service Manager将默认目录设置为c:\ Windows \ System32
。
如何从安装路径中阅读?
I follow the Microsoft guide to build a Windows service.
The appSettings.json
file is read when running from the Visual Studio or command line, but when the service DLL is executed from the Service Manager, it fails.
All variables populated from config remain empty remain empty.
The problem is that Windows Service Manager set the default directory to c:\windows\system32
.
How to read from installation path?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在Service Startup,将工作路径设置为以这种方式设置安装路径:
此修改确保将工作路径设置为安装路径,从而在服务管理器执行服务时可以正确访问配置文件。
At service startup, set the working path to the installation path this way:
This modification ensures that the working path is set to the installation path, allowing proper access to configuration files when the service is executed from the Service Manager.