Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 360
user3069540 Avatar asked Jan 02 '14 14:01

user3069540


2 Answers

I had the same error.

I was missing a reference to Microsoft.WindowsAzure.Diagnostics

like image 172
LivingOnACloud Avatar answered Oct 12 '22 13:10

LivingOnACloud


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!

like image 25
Amogh Natu Avatar answered Oct 12 '22 11:10

Amogh Natu