为什么在 ETW 会话中启用提供程序的 asp.net mvc 会引发错误?

问题描述

这是代码部分,这里抛出错误

_traceEventSession = new TraceEventSession(SessionName,TraceEventSessionoptions.Create);
_traceEventSession.EnableProvider(
                ClrTraceEventParser.ProviderGuid,Microsoft.Diagnostics.Tracing.TraceEventLevel.Verbose,(ulong)(ClrTraceEventParser.Keywords.Threading | ClrTraceEventParser.Keywords.Contention));

调用 EnableProvider 时出错

Error stack

在本地环境中一切正常,我不使用 KernelProvider,所以我真的不明白为什么会发生这种情况。此外,我在 .NET 公共语言运行时提供程序部分添加了 IIS_IUSRS 的所有权限,但它根本没有帮助。

enter image description here

解决方法

您需要将应用程序池的标识设置为LocalService:

enter image description here

enter image description here