阅文时长 | 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即可。

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

  1. 如何在ASP.NET Core程序启动时运行异步任务(3)

    原文:Running async tasks on app startup in ASP.NET Core (Part 3) 作者:Andrew Lock 译者:Lamond Lu 之前我写了两篇有关 ...

  2. 如何在ASP.NET Core程序启动时运行异步任务(1)

    原文:Running async tasks on app startup in ASP.NET Core (Part 1) 作者:Andrew Lock 译者:Lamond Lu 背景 当我们做项目 ...

  3. 如何在ASP.NET Core程序启动时运行异步任务(2)

    原文:Running async tasks on app startup in ASP.NET Core (Part 2) 作者:Andrew Lock 译者:Lamond Lu 在我的上一篇博客中 ...

  4. 记一次spring boot项目启动失败

    最近在macos下启动spring boot 项目的时候启动失败,报错信息如下: org.postgresql.util.PSQLException: 尝试连线已失败.at org.postgresq ...

  5. qt quick发布程序启动失败

    qt quick/qml 程序发布之后,程序启动不了 经过探究测试,程序启动的不了的情况下是因为有dll没有添加.在release文件夹下进行发布操作(不单独复制xx.exe拿出来),再次点击IDE的 ...

  6. 网络流媒体协议RTSP视频平台EasyNVR程序启动失败,端口被占用该如何解决?

    最近有很多用户反馈现场在启动EasyNVR的时候无法正常启动,我们以windows版本为例,启动界面如下: 如上图所示,截图显示10100端口被占用了,其实之前我们讲过国标GB28181视频平台Eas ...

  7. 一次zookeeper启动失败的解决过程

    大数据平台:MRS 8.1.2.2 最近集群出现了问题,zookeeper组件常常自动恢复,且造成了hive.hbase等组件在zookeeper上注册失败. 通过观察zookeeper日志,发现大量 ...

  8. linux tomcat启动失败的原因,Linux平台Tomcat启动失败问题排查

    部署在 Linux 服务器上边的 Tomcat服务通常在项目更新的时候需要重新启动,但是会由于各种原因,导致 Tomcat 启动失败,本文将以Linux 发行版 centOS 7 系统为例介绍两种 T ...

  9. service启动失败问题排查

    本文首发在我的个人博客:https://jlice.top/p/7ve9p/.欢迎大家前去参观,么么哒~ 我的电脑在启动时总会提示"Failed to start Load Kernel M ...

最新文章

  1. 兴趣部落老是显示无法连接服务器失败,qq兴趣部落为什么停运
  2. AngularJs+bootstrap搭载前台框架——准备工作
  3. Django 运行 runserver 端口占用,报错:Errno 10013
  4. 【python自动化办公02】word操作-word转pdf
  5. SpringMVC中注解的使用
  6. HTTP Status 403 - Access to the requested resource has been denied
  7. .NET Core开源API网关 – Ocelot中文文档
  8. securecrt哪个版本好用_电脑跑分测试软件哪个好?好用的电脑跑分软件推荐
  9. IDEA如何像Eclipse打开多个项目?
  10. js预览本地word文档_怎么免费下载百度文库付费文档?
  11. 【Spring】SpringBoot 如何使用JMX
  12. sprintf()函数的用法
  13. 基于ELK 7.50搭建elastalert 监控报警和权限控制
  14. 不一样的90后创业者:创业是另一种生活方式
  15. android post请求时报415错误,post请求传递JSON数据类型(415错误解决)
  16. 如何用python爬取下载微博视频_Python通过抓包和使用cookie爬取微博完全讲解(附视频)-阿里云开发者社区...
  17. java实现 蓝桥杯 算法提高 盾神与条状项链
  18. Dialog dismiss 失效的问题,
  19. 悲情陨落的十大民族品牌
  20. java bouncycastle生成数字证书工具类

热门文章

  1. 程序员:用代码改变世界
  2. CAN接口测试工装研究
  3. 剪视频一点都不难,多款超实用剪辑软件全方位评测!
  4. 行业实战 | 5G+边缘计算+“自由视角” 让体育赛事更畅快
  5. 软件架构-解密电商系统-互联网BAT商品详情缓存架构
  6. 雅思口语-Part1练习
  7. 宜信唐宁忠告北大毕业生 日进斗金不如守住初心
  8. OCA/OCP Oracle 数据库12c考试指南读书笔记:第3章: Installing Oracle Grid Infrastructure for a Stand-Alone Server
  9. 中国计量大学计算机专业在哪个校区,2021年中国计量大学有几个校区,大一新生在哪个校区...
  10. Python 基础 --- 变量类型