16

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.

w.brian
  • 16,296
  • 14
  • 69
  • 118
  • Which .NET version are you using? And which OS family? – Sandrino Di Mattia Jan 07 '13 at 10:10
  • .NET 4.5, and I can't figure out where I can configure or view the OS family for the web site. – w.brian Jan 07 '13 at 15:57
  • Are you using Windows Azure Web Sites or a Cloud Service with a Web Role? – Sandrino Di Mattia Jan 07 '13 at 19:24
  • It's a Azure Web Site, which I set up under the Cloud Service tab. See http://i.imgur.com/5tIEm.jpg . Once it creates the web site from there, it still doesn't consider it a Cloud Service, even though the option to create it is under the Cloud Service tab. A bit confusing, I know. – w.brian Jan 07 '13 at 19:54

3 Answers3

19

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.

Sandrino Di Mattia
  • 24,739
  • 2
  • 60
  • 65
  • Thank you. Will mark as answer once I'm able to verify this. – w.brian Jan 07 '13 at 21:50
  • My question (and it may be stupid) is this: If I publish my app as a site I can't use it in the way I expected BUT it is available at the URL (albeit with the error reported). If I publish as a web role (which is the way I first tried), it succeeds, takes up space, but isn't available at the url (i get the hostingstart.html page). So where is the app/role? should it be at the same url as it was when i published as a web site? – Mr AH Jan 25 '13 at 17:27
  • IGNORE ABOVE: it's very simple, I had also become confused between cloud web role and web site and created both with similar names! to find your app after publishing the role, it's the url in the last column under the "cloud services" section – Mr AH Jan 25 '13 at 17:42
12

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>
viperguynaz
  • 12,044
  • 4
  • 30
  • 41
  • All the references are good -- 1.8 and copy local. You may be onto something with the GuestOs, in my ServiceConfiguration, osFamily was set to 1. Unfortunately, I get the same error after changing it to 3. – w.brian Jan 07 '13 at 17:03
  • 1
    First try the assembly binding redirect (updated answer), then try enabling remote access as well and RDPing into the instance to verify the DLL verios is copied correctly. site files will be in either E: or F:\sitesroot\0 – viperguynaz Jan 07 '13 at 17:28
  • The dependentAssembly redirect didn't work, unfortunately. I'm a bit of an Azure noob -- How do I RDP into the instance? One thing I've learned through this question is that I'm apparently using some preview Web Site feature, and therefore isn't a "typical" cloud service. I really appreciate your help. – w.brian Jan 07 '13 at 18:19
0

Since you're getting the error when trying to start the DiagnosticMonitor, can you check that you are referencing the 1.8 version of Microsoft.WindowsAzure.Diagnostics too?

It should be located at C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-06\ref.

Evan
  • 5,925
  • 6
  • 33
  • 35
  • Microsoft.WindowsAzure.Diagnostics is being referenced from the location you specified. – w.brian Jan 07 '13 at 14:25
  • 1
    Are you deploying a [Cloud Service Web Role](http://www.windowsazure.com/en-us/home/features/cloud-services/) or a [Web Site](http://www.windowsazure.com/en-us/home/features/web-sites/)? – Evan Jan 07 '13 at 15:18
  • 1
    Other things to try if you're running a Cloud Service Web Role would be to make sure you're running at least Guest OS v1.21 and at least .net 4.0 – Evan Jan 07 '13 at 15:23
  • I'm fairly certain it's a Web Site, even though the Azure portal doesn't make the distinction very clear. I've clicked on the "Cloud Services" tab and created a website from there, and I think that, in the context of your question, it's a Web Site. I can't find where I can configure the guest OS for it, whereas I did find I could for a service bus. I really appreciate your help, by the way. – w.brian Jan 07 '13 at 15:57
  • If you created it from the cloud services tab it's a web role. There's a separate tab for creating websites but they're a preview feature that you have to request access to for your subscription. You won't have the websites tab until you request access – levelnis Jan 07 '13 at 16:41
  • I have a 3-month trial subscription that I just recently signed up for, and it looks like I do have the preview features, see: http://i.imgur.com/ymiTy.jpg . Ideally I could continue to use these, because the automatic deployment from git is amazing. – w.brian Jan 07 '13 at 16:52