Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=1.8.0.0 when deployed to the cloud

w.brian picture w.brian · Jan 7, 2013 · Viewed 36.3k times · Source

I have an MVC 4 app that runs fine locally but fails with this message when deployed to Azure:

[FileNotFoundException: Could not load file or assembly Microsoft.WindowsAzure.ServiceRuntime, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.GetDefaultStartupInfoForCurrentRoleInstance() +0 Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener..ctor() +40

I've made sure I referenced Microsoft.WindowsAzure.ServiceRuntime version 1.8 and have it set to copy local.

Answer

Sandrino Di Mattia picture Sandrino Di Mattia · Jan 7, 2013

So from your screenshot it looks like you created a Web Site (which isn't a Cloud Service or a Web Role). The assemblies Microsoft.WindowsAzure.Diagnostics and Microsoft.WindowsAzure.ServiceRuntime cannot be used in a Web Site.

If you want to create a Web Role, open Visual Studio > File > New Project > Cloud > Windows Azure Cloud Service > Add an MVC Web Role > OK. Once you're done, right click the Azure project and choose Publish. This will allow you to create a new Cloud Service which will contain your Web Role. And if you create your project like this you will be able to use the Microsoft.WindowsAzure.Diagnostics and Microsoft.WindowsAzure.ServiceRuntime assemblies.