Jer*_*oyd 16 c# azure azure-diagnostics newrelic
刚刚从假期回来,当我遇到这个错误时,他们在我们的应用程序中进行了一些小改动:
找不到类Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,Microsoft.WindowsAzure.Diagnostics,Version = 2.1.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35的类型.
在从假期回来之前,代码已经完美运行.它是在3周前发布到Azure的,它现在在那里遇到了同样的问题.本地我尝试通过删除添加添加以下配置部分来修复它:
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
</add>
</listeners>
</trace>
</system.diagnostics>
Run Code Online (Sandbox Code Playgroud)
添加添加和删除对程序集的引用:

当我在本地调试项目时,Visual Studio在以下行中断:
NewRelic.Api.Agent.NewRelic.IgnoreTransaction();
Run Code Online (Sandbox Code Playgroud)
直到2天前,这一直在本地和生产中工作(根据错误日志).
完整堆栈跟踪:
[ConfigurationErrorsException: Couldn't find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.]
System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData) +6755367
System.Diagnostics.TypedElement.BaseGetRuntimeObject() +45
System.Diagnostics.ListenerElement.GetRuntimeObject() +83
System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() +143
System.Diagnostics.TraceInternal.get_Listeners() +181
System.Diagnostics.TraceInternal.WriteLine(String message) +119
System.Diagnostics.Trace.WriteLine(String message) +4
NewRelic.Api.Agent.NewRelic.IgnoreTransaction() +13
Linklicious2.Controllers.ApiController.GetLinksToPing(Boolean test) +46
lambda_method(Closure , ControllerBase , Object[] ) +98
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +214
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
System.Web.Mvc.Controller.ExecuteCore() +106
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9631764
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Run Code Online (Sandbox Code Playgroud)
如果您没有在模拟器中运行,那么请在此处查看我的答案 - 如何解决Windows Azure诊断运行时错误(无法创建WindowsAzure.Diagnostics,版本= xx,Culture =中性,PublicKeyToken = xx.基本上,只需添加:
<filter level="TraceEventType.Error" />
Run Code Online (Sandbox Code Playgroud)
在该<listeners><add>部分.
虽然Microsoft.WindowsAzure.Diagnostics.dll在我的Cloud Service软件包中有一个项目参考和本地副本,但事实证明,您MonAgentListener.dll在软件包中也需要一个副本-添加该文件后,它又开始工作。
具体来说,我使用的是Microsoft.WindowsAzure.Diagnostics.dllversion 2.8.0.0,大小为35,608 bytes(34.7KB)。与相同的文件C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Microsoft.WindowsAzure.Diagnostics.dll。
和MonAgentListener.dll版本33.1.5.0,74,448 bytes(72.7KB)的大小,而且是同一个文件C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\MonAgentListener.dll。
不要将此的35KB版本Microsoft.WindowsAzure.Diagnostics.dll与C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Windows Azure Tools Diagnostics 1.0\Microsoft.WindowsAzure.Diagnostics.dll或C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Windows Azure Tools\v2.9\Microsoft.WindowsAzure.Diagnostics.dll都标记为version 的311KB版本混淆2.4.6489.4。
我的项目使用的是Azure PaaSDiagnostics 扩展(这是Azure PowerShell和Azure门户所使用的),而不是Microsoft.WindowsAzure.Plugins.Diagnostics 插件,而该插件是Cloud Service诊断程序的较旧版本(使用的是现在已过时的“插件”模型,而不是当前的“扩展”模型) )。鉴于扩展旨在与任何Cloud Service配合使用-事实证明,您仍然需要引用这些程序集并将它们包含在您的软件包中- 扩展将无法为您完成。
但要使情况更加混乱:如果您有VS Cloud Service项目,那么如果您使用VS的Cloud Project部署系统,则Visual Studio 2015甚至Visual Studio 2017仍将使用较旧的插件系统。
(鉴于“云服务”系统是旧系统,仅由较旧的Azure“服务管理” API支持,而当前的“资源管理” API和系统不支持,因此,MS并未投资于改进Visual Studio中用于Cloud Services的工具-但是,在我研究应该做的事情时,插件与扩展(对于诊断程序和远程桌面)之间的这种混淆使我的项目延迟了数周。
还要确保Microsoft.WindowsAzure.ServiceRuntime.dll已Copy Local = True设置您的Cloud Service引用。这还将复制文件WindowsAzureEventSource.dll并将WindowsAzureTelemetryEvents.dll其复制到输出-并确保所有3个文件都包含在您的Cloud Service Package中。
确保您的Cloud Service软件包文件中包含这些文件(以便在部署E:\approot时将它们部署到)
File Version Size (bytes)
Microsoft.WindowsAzure.Diagnostics.dll 2.8.0.0 35,608
MonAgentListener.dll 33.1.5.0 74,448
Microsoft.WindowsAzure.ServiceRuntime.dll 2.7.1198.768 158,624
WindowsAzureEventSource.dll 2.7.1198.768 83,872
WindowsAzureTelemetryEvents.dll 2.7.1198.768 24,992
Run Code Online (Sandbox Code Playgroud)另外,请确保您的Cloud Service Worker Role项目具有一个App.config带有以下内容的文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,Microsoft.WindowsAzure.Diagnostics,Version=2.8.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<!-- Ignore the VS-generated message "The attribute 'type' is not allowed." -->
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
11840 次 |
| 最近记录: |