.net7 workservice 发布成服务报错问题错误模块名称: KERNELBASE.dll

Application: QJWL_WorkerServerTime.exe

CoreCLR Version: 7.0.323.6910

.NET Version: 7.0.3

Description: The process was terminated due to an unhandled exception.

Exception Info: System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The expected physical path was 'C:\Windows\system32\appsettings.json'.

at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info)

at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)

at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()

at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)

at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()

at Program.<Main>$(String[] args) in C:\WooCode\qjwl_timer\QJWL_WorkerServerTime\QJWL_WorkerServerTime\Program.cs:line 10

错误原因:1 模块名称: KERNELBASE.dll 这个在运行bat时使用管理员身份运行

错误2:

not found and is not optional. The expected physical path was 'C:\Windows\system32\appsettings.json'.

原因由于代码如下:

var confbuilder = new ConfigurationBuilder()
 .SetBasePath(Directory.GetCurrentDirectory())
  
    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
IConfigurationRoot configuration = confbuilder.Build();

修改代码如下:

var confbuilder = new ConfigurationBuilder()
 //.SetBasePath(Directory.GetCurrentDirectory())
    .SetBasePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
IConfigurationRoot configuration = confbuilder.Build();

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,KERNELBASE.dll是Windows操作系统的一个核心动态链接库文件。它提供了许多系统级的函数和服务,用于处理应用程序的异常和错误处理。当开机自启动程序报错模块为C:\WINDOWS\System32\KERNELBASE.dll时,可能是由于该动态链接库文件本身出现了问题导致的。 要解决这个问题,可以尝试以下几个步骤: 1. 检查系统文件完整性:运行命令提示符(cmd.exe)作为管理员,并执行sfc /scannow命令。这将扫描并修复系统文件中的任何损坏或缺失。 2. 更新操作系统:确保你的操作系统是最新的,可以通过Windows更新来获取最新的修补程序和安全更新。 3. 检查应用程序兼容性:如果该开机自启动程序是第三方应用程序,尝试更新或重新安装该程序,以确保它与当前的操作系统版本兼容。 4. 检查系统日志:查看系统事件日志,以获取更多关于错误的详细信息。可能会有其他错误或警告信息与KERNELBASE.dll相关联,这可以帮助你更好地理解问题的根本原因。 请注意,以上建议仅供参考,具体解决方法可能因个人情况而异。如果问题仍然存在,建议联系相关技术支持或咨询专业人士以获取进一步的帮助。 #### 引用[.reference_title] - *1* *2* *3* [Windbg介绍](https://blog.csdn.net/u010607621/article/details/106764850)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值