How to solve Windows Azure Diagnostic Runtime Error (Could not create WindowsAzure.Diagnostics, Version=xx, Culture=neutral, PublicKeyToken=xx

早过忘川 提交于 2019-12-18 04:04:29

问题


privateLibManager libManager;
private LibManager Connect()
{
   this.libManager=new LibManager();//here we are getting an error
}

Error:

The type initializer for 'SWConfigDataClientLib.LibManager' threw an exception

Inner Exception:

Could not create Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics,Version=2.2.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35.

Source

IpPbxCDSClientLib


回答1:


First make sure you have added references to Microsoft.WindowsAzure.Diagnostics from the SDK folders (typically c:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\v2.2\ref\Microsoft.WindowsAzure.Diagnostics.dll)

Next, if you are not running your project in the emulator (i.e. the cloud project set as the startup project), then set the trace filter level to TraceEventType.Error or TraceEventType.None to avoid trying to write verbose Azure messages to the trace listener. In you web or app config:

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



回答2:


I had the same error.

I was missing a reference to Microsoft.WindowsAzure.Diagnostics




回答3:


Ok So even I had this exception being thrown continuously. However, my case was a little different.

I wanted to get rid of this reference as it was no longer required in the project. So I removed it from the references. But while running the application, I started getting this exception at a Debug.WriteLine(...); statement which suggested that the reference was required.

On further analysis, I found that the below section was present in the project's app.config file which was the cause of the exception.

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

After removing the reference AND also removing the above section from config file, the issue got fixed.

Hope this helps!




回答4:


Make sure you have added this reference to your project Microsoft.Azure.Plugins.Diagnostics.dll



来源:https://stackoverflow.com/questions/20885343/how-to-solve-windows-azure-diagnostic-runtime-error-could-not-create-windowsazu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!