Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 962
w.brian Avatar asked Jan 07 '13 02:01

w.brian


2 Answers

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.

like image 74
Sandrino Di Mattia Avatar answered Oct 26 '22 06:10

Sandrino Di Mattia


Check the references in your project and make sure that all Azure references are marked Copy Local = True. Also since the app is looking for Runtime version 1.8, you are obviously using at least one assembly from SDK 1.8 - C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-10\ref... NOTE: 2012-10. Then check the reference versions in use:

  • Diagnostics: 1.8.0.0
  • Runtime: 1.8.0.0

This assembly mis-match typically happens because you have different SDK versions referenced and/or your ref's are not marked copy local = true.

As for Azure taxonomy, there are Websites (on portal under websites) and there are Cloud Services which can have either WebRoles (websites, wcf services) or WorkerRoles (backend processing).

For CloudServices, the OS Family and GuestOS are specified in the ServiceConfiguration.cscfg file in the "ServiceConfiguration" element:

<ServiceConfiguration serviceName="MyWebRole" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2012-10.1.8">

osFamily 2 = Server 2008R2 and 3 = Server 2012. The osVersion specifies the GuestOS and should almost always be "*" for the latest version.

If all else fails, and the correct DLL is deplyed in the bin, try adding an assembly binding redirect in the web.config:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="1.0.0.0-1.8.0.0" newVersion="1.8.0.0" />
</dependentAssembly>
like image 12
viperguynaz Avatar answered Oct 26 '22 06:10

viperguynaz