问题描述

在使用App Service的过程中,发现应用频繁出现503错误,通过Kudu站点获取到Logfiles。

Eventlog.xml 文件中,发现大量的 Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener 异常,并且引起 w3wp.exe 进程终止。

<Event>
<System>
<Provider Name=".NET Runtime"/>
<EventID>1026</EventID>
<Level>1</Level>
<Task>0</Task>
<Keywords>Keywords</Keywords>
<TimeCreated SystemTime="2022-09-22T09:52:50Z"/>
<EventRecordID>421882843</EventRecordID>
<Channel>Application</Channel>
<Computer>RD0003FF0C13B3</Computer>
<Security/>
</System>
<EventData>
<Data>Application: w3wp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Configuration.ConfigurationErrorsException at System.Diagnostics.TraceUtils.GetRuntimeObject(System.String, System.Type, System.String) at System.Diagnostics.TypedElement.BaseGetRuntimeObject() at System.Diagnostics.ListenerElement.GetRuntimeObject() at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() at System.Diagnostics.TraceInternal.get_Listeners() at System.Diagnostics.TraceInternal.WriteLine(System.String) at System.Diagnostics.Debug.WriteLine(System.String) at Microsoft.Web.Compilation.Snapshots.SnapshotHelper.TakeSnapshotTimerCallback(System.Object) at System.Threading.TimerQueueTimer.CallCallbackInContext(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.TimerQueueTimer.CallCallback() at System.Threading.TimerQueueTimer.Fire() at System.Threading.TimerQueue.FireNextTimers() at System.Threading.TimerQueue.AppDomainTimerCallback(Int32) </Data>
</EventData>
</Event>
<Event>
<System>
<Provider Name="ASP.NET 4.0.30319.0"/>
<EventID>1325</EventID>
<Level>1</Level>
<Task>0</Task>
<Keywords>Keywords</Keywords>
<TimeCreated SystemTime="2022-09-22T10:02:53Z"/>
<EventRecordID>422485625</EventRecordID>
<Channel>Application</Channel>
<Computer>RD0003FF0C13B3</Computer>
<Security/>
</System>
<EventData>
<Data>An unhandled exception occurred and the process was terminated. Application ID: /LM/W3SVC/152666399/ROOT Process ID: 6092 Exception: System.Configuration.ConfigurationErrorsException Message: Couldn't find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. StackTrace: at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData) at System.Diagnostics.TypedElement.BaseGetRuntimeObject() at System.Diagnostics.ListenerElement.GetRuntimeObject() at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() at System.Diagnostics.TraceInternal.get_Listeners() at System.Diagnostics.TraceInternal.WriteLine(String message) at System.Diagnostics.Debug.WriteLine(String message) at Microsoft.Web.Compilation.Snapshots.SnapshotHelper.TakeSnapshotTimerCallback(Object stateInfo) at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.TimerQueueTimer.CallCallback() at System.Threading.TimerQueueTimer.Fire() at System.Threading.TimerQueue.FireNextTimers() at System.Threading.TimerQueue.AppDomainTimerCallback(Int32 id)</Data>
</EventData>
</Event>

在启用了 Proactive Crash Monitoring in Azure App Service 后,当应用再次应为没有处理的异常(24小时内发生3次)就会自动抓取Memory DUMP进行分析。完整的异常日志为:


========================================================
Dump Analysis for w3wp__xxxxxxxx__PID__9644__Date__09_22_2022__Time_02_59_27AM__239__Second_Chance_Exception_E0434352.dmp
========================================================
Thread 7984
ExitCode E0434352
ExitCodeString CLR EXCEPTION
DefaultHostName xxxxxxxxxx.chinacloudsites.cn
Managed Exception = System.Configuration.ConfigurationErrorsException:Couldn't find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
CallStack - Managed Exception
========================================================
System.Diagnostics.TraceUtils.GetRuntimeObject(System.String, System.Type, System.String)
System.Diagnostics.TypedElement.BaseGetRuntimeObject()
System.Diagnostics.ListenerElement.GetRuntimeObject()
System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
System.Diagnostics.TraceInternal.get_Listeners()
System.Diagnostics.TraceInternal.WriteLine(System.String)
System.Diagnostics.Debug.WriteLine(System.String)
Microsoft.Web.Compilation.Snapshots.SnapshotHelper.TakeSnapshotTimerCallback(System.Object)
System.Threading.TimerQueueTimer.CallCallbackInContext(System.Object)
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
System.Threading.TimerQueueTimer.CallCallback()
System.Threading.TimerQueueTimer.Fire()
System.Threading.TimerQueue.FireNextTimers()
System.Threading.TimerQueue.AppDomainTimerCallback(Int32)
CallStack - Crashing Thread
========================================================
HelperMethodFrame
System.Diagnostics.TraceUtils.GetRuntimeObject(System.String, System.Type, System.String)
System.Diagnostics.TypedElement.BaseGetRuntimeObject()
System.Diagnostics.ListenerElement.GetRuntimeObject()
System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
System.Diagnostics.TraceInternal.get_Listeners()
System.Diagnostics.TraceInternal.WriteLine(System.String)
System.Diagnostics.Debug.WriteLine(System.String)
Microsoft.Web.Compilation.Snapshots.SnapshotHelper.TakeSnapshotTimerCallback(System.Object)
System.Threading.TimerQueueTimer.CallCallbackInContext(System.Object)
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
System.Threading.TimerQueueTimer.CallCallback()
System.Threading.TimerQueueTimer.Fire()
System.Threading.TimerQueue.FireNextTimers()
System.Threading.TimerQueue.AppDomainTimerCallback(Int32)
DebuggerU2MCatchHandlerFrame
ContextTransitionFrame
DebuggerU2MCatchHandlerFrame Native Call Stack
========================================================
KERNELBASE!RaiseException
clr!RaiseTheExceptionInternalOnly
clr!IL_Throw
mscorlib_ni
mscorlib_ni
mscorlib_ni
mscorlib_ni
mscorlib_ni
mscorlib_ni
clr!CallDescrWorkerInternal
clr!CallDescrWorkerWithHandler
clr!MethodDescCallSite::CallTargetWorker
clr!AppDomainTimerCallback_Worker
clr!ManagedThreadBase_DispatchInner
clr!ManagedThreadBase_DispatchMiddle
clr!ManagedThreadBase_DispatchOuter
clr!ManagedThreadBase_DispatchInCorrectAD
clr!Thread::DoADCallBack
clr!ManagedThreadBase_DispatchInner
clr!ManagedThreadBase_DispatchMiddle
clr!ManagedThreadBase_DispatchOuter
clr!ManagedThreadBase_FullTransitionWithAD
clr!AppDomainTimerCallback
clr!ThreadpoolMgr::AsyncTimerCallbackCompletion
clr!UnManagedPerAppDomainTPCount::DispatchWorkItem
clr!ThreadpoolMgr::ExecuteWorkRequest
clr!ThreadpoolMgr::WorkerThreadStart
clr!Thread::intermediateThreadProc
kernel32!BaseThreadInitThunk
ntdll!__RtlUserThreadStart
ntdll!_RtlUserThreadStart

这个问题是什么原因呢?

问题解答

在Eventlog.xml文件中,已经发现了此异常的根本原因是:Couldn’t find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Culture=neutral, PublicKeyToken=31bf3856ad364e35

这个问题发生的原因是在项目中使用了 ”Microsoft.WindowsAzure.Diagnostics.dll“, 这个 dll 可以在云服务(Azure Cloud Service)中使用,但是它与App Service不相容,不能在App Service中使用。否则,就不停的引发异常导致W3WP.EXE重启。

通过下面两方面来解决这个问题:

1)检查应用项目文件,移除全部 Microsoft.WindowsAzure.Diagnostics.dll 的引用

2)检查应用的 web.config 文件,如果存在 system.diagnostics 中含有 DiagnosticMonitorTraceListener 内容,则全部移除

 <system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>

操作以上两步骤后,希望能解决因为Couldn’t find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener 问题。

参考资料

Preventing crashes due to DiagnosticMonitorTraceListener :https://azure.github.io/AppService/2021/06/09/Apps-on-App-Services-crash-due-to-DiagnosticMonitorTraceListener.html

Proactive Crash Monitoring in Azure App Service : https://azure.github.io/AppService/2021/03/01/Proactive-Crash-Monitoring-in-Azure-App-Service

【Azure 应用服务】App Service频繁出现 Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener 异常分析的更多相关文章

  1. 【应用服务 App Service】快速获取DUMP文件(App Service for Windows(.NET/.NET Core))

    问题情形 当应用在Azure 应用服务App Service中运行时,有时候出现CPU,Memory很高,但是没有明显的5XX错误和异常日志,有时就是有异常但是也不能明确的指出具体的代码错误.当面临这 ...

  2. 【应用服务 App Service】Azure 应用服务测试网络访问其他域名及请求超时限制(4分钟 ≈ 230秒)

    测试App Service是否可以访问其他DNS 当应用服务(Azure App Service)创建完成后,想通过ping命令来查看是否可以访问其他站点或解析DNS,但是发现ping命令无法使用.这 ...

  3. 【应用服务 App Service】App Service中抓取网络日志

    问题描述 众所周知,Azure App Service是一种PaaS服务,也就是说,IaaS层面的所有内容都由平台维护,所以使用App Service的我们根本无法触碰到远行程序的虚拟机(VM), 所 ...

  4. 【应用服务 App Service】Azure App Service 中如何安装mcrypt - PHP

    问题描述 Azure App Service (应用服务)如何安装PHP的扩展 mcrypt(mcrypt 是php里面重要的加密支持扩展库) 准备条件 创建App Service, Runtime ...

  5. 【应用服务 App Service】解决无法从Azure门户SSH登录问题

    问题描述 中国区的Azure App Service(应用服务)已经支持创建Docker并选择Linux环境.在使用中,我们可以继续通过kudu站点的方式登录查看站点的一些日志及部署文件.它的登录方式 ...

  6. 【应用服务 App Service】在Azure App Service中使用WebSocket - PHP的问题 - 如何使用和调用

    问题描述 在Azure App Service中,有对.Net,Java的WebSocket支持的示例代码,但是没有成功的PHP代码. 以下的步骤则是如何基于Azure App Service实现PH ...

  7. 【应用服务 App Service】发布到Azure上的应用显示时间不是本地时间的问题,修改应用服务的默认时区

    问题情形 应用程序发布到App Service后,时间显示不是北京时间,默认情况为UTC时间,比中国时间晚 8 个小时. 详细日志 无 问题原因 Azure 上所有的服务时间都采用了 UTC 时间. ...

  8. 【应用服务 App Service】当遇见某些域名在Azure App Service中无法解析的错误,可以通过设置指定DNS解析服务器来解决

    问题情形 当访问部署在Azure App Service中的应用返回 "The remote name could not be resolved: ''xxxxxx.com'" ...

  9. 【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误

    问题情形 使用EF Core访问数据库,在本地运行正常,发布到App Service后,偶尔出现了Cannot create a DbSet for ** because this type is n ...

随机推荐

  1. 从matlab的bwmorph函数的'majority'参数中扩展的一种二值图像边缘光滑的实时算法。

    在matlab的图像处理工具箱中,有一系列关于Binary Images的处理函数,都是以字母bw开头的,其中以bwmorph函数选项最为丰富,一共有'bothat'.'branchpoints'.' ...

  2. qbxt数学五一Day4

    目录 1. 随机试验 2. 概率 1. 平凡 2. 条件概率 3. 期望 习题 1 2 3 4 1. 随机试验 定义: 不能预先确知结果 试验之前可以预测所有可能结果或范围 可以在相同条件下重复实验 ...

  3. 开源一个自动整理B站UWP客户端软件进行批量下载的视频文件的小工具BiliVideosReoganizeHelper​

    ​ 大家都知道B站是一个很受欢迎的视频学习网站,上面有很多无私的up主上传了大量优秀的教学视频,在此向B站致敬,向广大UP主致敬. 有时,我们需要下载收藏一些视频,以防止以后找不到了.那么我们可以用B ...

  4. 1个小时!从零制作一个! AI图片识别WEB应用!

    0 前言 近些年来,所谓的人工智能也就是AI. 在媒体的炒作下,变得神乎其神,但实际上,类似于图片识别的AI,其原理只不过是数学的应用. 线性代数,概率论,微积分(著名的反向传播算法). 大家觉得这些 ...

  5. Kettle需求场景复现

    前置说明 遍历文件夹下的文件,读取所有的sheet页(指定的sheet)落库 读取execl文件和csv文件,获得文件中sheet/csv数据,进行落库,并增加字段实现更新: 如果execl中存在两个 ...

  6. ArkUI 自定义组件

    基础入门 组件可以把一段代码封装起来,目的是提高这一段代码的复用率,并且也可以减少开发人员多次编写相同的代码.一旦组件定义好了之后,在页面中只需要通过<element /> 标签引入进来就 ...

  7. Excel 统计函数(三):AVERAGE 和 AVERAGEA

    AVERAGE 只能计算纯数值,如果引用的单元格是非数值,不会被计入总数:AVERAGEA 可以计算逻辑值.代表数字的文本等. 假如下列有一个表格,分别使用两种算术评价函数计算平均值. [过程]AVE ...

  8. Windows批量修改文件

    如图我是建立了壁纸文件夹 Windows自带的排序方式 如何不用自带的呢? 在这个文件夹里面建一个.txt文件 如下 ok第二步骤 将UTF-8格式改为ANSI格式 点击文件-另存为ANSI格式-替换 ...

  9. Python入门系列(一)安装环境

    python是什么 python是一门很受欢迎的语言,除了不能生孩子以外,其它都可以做. 它擅长的领域是脚本工具和科学数据这一块,比如大数据,数据分析什么的. python安装 为了演示和验证教程可用 ...

  10. Prometheus教程

    Prometheus介绍 主要特征 使用时间序列数据(tsdb)的多维度数据模型 灵活的查询语言(PromQL) 不依赖分布式存储,单个节点是自主的 通过http请求拉取(pull)时间序列数据(ts ...