Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics' or one of its dependencies Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics' or one of its dependencies azure azure

Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics' or one of its dependencies


It looks like this is happening when your application starts. Take a look at your web.config, do you have a trace listener pointing to the Microsoft.WindowsAzure.Diagnostics assembly? That might be the reason why your application is not working.

First, take a look at your assembly references and delete Microsoft.WindowsAzure.Diagnostics should it be present (just to be sure we don't use old versions). Then, add a reference to Microsoft.WindowsAzure.Diagnostics, but make sure this is version 1.7.0.0.

You should find the right version of this assembly in: C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-06\ref


I know this is an old topic but it's still the top Google result for "Could not load file or assembly Microsoft.WindowsAzure.Diagnostics", so here is what I did:

This was happening to me with the Azure SDK 2.7.1 and Visual Studio 2013. Somewhere between upgrading to Windows 10 and Azure SDK 2.7, something didn't get installed right. I tried reinstalling the Azure SDK, upgrading to Visual Studio 2015 but neither worked. I finally had to change the following line in my app.config:

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

to

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

Notice the change from "2.7.0.0" to "2.5.0.0". For me, Microsoft.WindowsAzure.Diagnostics 2.7.0.0 DLL did not exist. Reverting back to 2.5.0.0 works fine. I'd still like to find the root cause but I have more important things to move on to. Hope this helps!


Adding to Sandrinio's answer (sorry I don't have privilege) I had a similar error where 1.7.0.0 was being referenced but this section in my web.config pointed to version 1.0.0.0

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

I commented it out and the problem was resolved.