c# - 有时窗口服务无法在机器重新启动时启动,手动启动并正常工作
问题描述
我有一个奇怪的行为将 asp.net web api 作为window service
. 50% 的时间机器重新启动,然后服务不会自动启动,50% 的时间它正确启动。我已将其设置为自动延迟启动,这取决于另一项服务的启动。
当它无法自动启动并且我正在查看事件查看器时,我可以看到下面的应用程序错误,
CoreCLR Version: 4.700.21.31506
.NET Core Version: 3.1.17
Description: The process was terminated due to an unhandled exception.
Exception Info: System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at Microsoft.Extensions.Hosting.Internal.Host.StopAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.WaitForShutdownAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at XXX.Program.Main(String[] args)
和“服务控制管理器”事件一样,
The "XXX" service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.
现在,当我在失败后手动启动它时,它启动时没有任何错误。
问题是,在 10 次重启中,为什么有时服务启动时没有任何错误,有时却抛出错误?它的解决方案是什么?它等待启动和失败的最大时间是多少?我可以增加一些时间线吗?
解决方案
推荐阅读
- c++ - 通过 M1 芯片上的 Google 测试库编写单元测试时,未找到架构 arm64 的符号
- sql - CASTING to NUMERIC in SQL
- php - How To Send Cookies To A Website Through Laravel Panel Using PHP?
- javascript - 动态加载内容保留“在新选项卡中打开”功能
- web-services - 服务接入点连接
- javascript - call(force.drag)的含义
- c# - 如何返回任务
- > 来自 dapper 的“从表中选择 *”,而不必再次从第一个查询中查询结果 id?
- python - 尝试模拟 2 个骰子以了解相同结果的百分比
- python-3.x - 如果输出中有变量,是否有办法将其投入使用?
- c# - Unity 未在检查器中显示自定义序列化类字段