记一次.Net Core程序启动失败的排查过程


阅文时长| 2分钟字数统计| 3212字符
主要内容| 1、引言&背景 2、排查.NetCore启动失败详细过程 3、声明与参考资料
『记一次.Net Core程序启动失败的排查过程』
编写人| SCscHero 编写时间| 2021/12/23 PM2:6
文章类型| 系列完成度| 已完成
座右铭每一个伟大的事业,都有一个微不足道的开始。

一、引言&背景   完成度:100%

a) 事件脉络

昨日在SIT环境做发布,发布后访问发现变成了503,之后又变成了500.0,而后又变成了500.31。如下异常及图,于是开始排查。

  1. 503,Service Unavailable,可能是网站超过了IIS限制。博主判断不存在此种情况,也不符合特征。于是查找了应用程序池,发现其中的应用被停用了。于是重启了应用程序池。这时候发现报的错不一样了。

  2. 于是开始排查部署,可能是之前部署的方式不正确,造成.NetCore启动有一定问题,于是打开了.NetCore程序的配置。开启启动日志监控。根据启动日志发现了一些信息,进而排查问题。最终解决。如下是.NetCore启动失败的一些返回信息:

HTTP Error 500.0 - ANCM In-Process Handler Load Failure
Common causes of this issue:
●The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
●The in process request handler, Microsoft.AspNetCore.Server.lIS, was not referenced in the application.
●ANCM could not find dotnet.
Troubleshooting steps:
●Check the system event log for error messages
●Enable logging the application process' stdout messages
●Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft. com/fwlink/?LinklD=2028526
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Specific error detected by ANCM:
It was not possible to find any compatible framework version The framework 'Microsoft.AspNetCore.App', version '2.2.0' (x64)was not found. - The following frameworks were found: 2.1.30 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] 3.1.18 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] 5.0.9 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] 6.0.0-rc.1.21452.15 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] You can resolve the problem by installing the specified framework and/or SDK. The specified framework can be found at: - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=2.2.0&arch=x64&rid=win10-x64
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028526
  1. 最终根据.NetCore启动日志,发现了缺失了.NetCore依赖包JSON文件,如第二章节。

b) 应用场景

  • .NetCore启动报错。

二、排查.NetCore启动失败详细过程   完成度:100%

a) 配置记录启动错误日志

如果是寄托于IIS,则在web.config中加入一段配置。stdoutLogEnabled值设置为true即可。Arguments值设置为应用名称即可。

<aspNetCore processPath="dotnet"
        arguments=".\MyApp.dll"
        stdoutLogEnabled="true"
        stdoutLogFile=".\logs\stdout">
</aspNetCore>

配置完后则在日志路径下可找到日志文件,如图:

b) 详细信息

如图,日志显示缺失了runtimeconfig.json以及deps.json文件。

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'D:\MCSSolution\XXXXX\publish\'.
Failed to run as a self-contained app. If this should be a framework-dependent app, add the D:\MCSSolution\XXXXX\publish\XXXXX.runtimeconfig.json file specifying the appropriate framework.
Application startup exception: System. IO. FileNotFoundException: Could not find file
'D: \MCSSolution\XXXXX\publish\XXXX.deps.json'.
File name: 'D:'\publish\XXXX. deps. json'
at System. I0. Filestream. ValidateF ileHandle(SafeF ileHandle fileHandle)
at System. I0. FileStream. CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System. IO. FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System. IO. FileStream.ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System. IO.File .OpenRead(String path)
at Microsoft.Extensions.DependencyModel. Filewrapper.OpenRead(String path)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadContext(IDependencyContextReader reader, string location)
at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)
at Microsoft.Extens ions.DependencyModel.DependencyContext.Load(Assembly assembly)
at Microsoft.AspNetCore.MvC.ApplicationParts .Applicat ionAssembliesProvider.LoadDependencyContext(Assembly assembly)
at Microsoft.AspNetCore. MvC .ApplicationParts.ApplicationAssembliesProvider.ResolveAssemblies
(Assembly entryAssembly)+MoveNext()
at Microsoft.AspNetCore.Mvc.ApplicationParts.Applicat ionPartManager.PopulateDefaultParts
(String entryAssemblyName)
at Microsoft.Extens ions.DependencyInjection.MvcCoreServiceCollectionExtens ions.GetApplicationPa
rtManager(IServiceCollection services)

三、声明与参考资料   完成度:100%

原创博文,未经许可请勿转载。

如有帮助,欢迎点赞、收藏、关注。如有问题,请评论留言!如需与博主联系的,直接博客私信SCscHero即可。

文章出处:https://www.cnblogs.com/SCscHero/p/15819609.html

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
管理员
上一篇:C# ASP.NET Core开发学生信息管理系统(三)
下一篇:WPF_15_格式化绑定的数据
评论列表

发表评论

评论内容
昵称:
关联文章

.Net Core程序启动失败排查过程
.NET 某化妆品 webapi 卡死分析
.NET 某市附属医院 Web程序 偶发性CPU爆高分析
数据库查询优化记录
本地正常上线接口报404
.NET 某药品仓储管理系统 卡死分析
.NET 某妇产医院 WPF内存溢出分析
WinDbg 分析 .NET 某工厂MES系统 内存泄漏分析
.NET 某智能交通后台服务 CPU爆高分析
.NET 某消防物联网 后台服务 内存泄漏分析
.NET Core定时任务(控制台程序
.Net启动程序报错:It was not possible to find any compatible framework version
.NET IIS第一访问慢,程序池被回收问题,IIS初始化(启用预加载)
IIS初始化(预加载),解决第一访问慢,程序池被回收问题
支付宝:联调排查工具使用介绍
熔断和降级初步详解实现(NET Core控制台输出讲解Polly)
C# ASP.NET Core开发学生信息管理系统(
解决Nancy参数绑定“bug”开始发布自己第一个nuget包(上篇)
企业项目实战.Net Core +FastReport教程|制作报表模板
ASP.NET+MVC入门踩坑笔记 () 创建项目 项目配置运行 以及简单Api搭建

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码