Friday, February 17, 2017

Could not load file or assembly Microsoft.WindowsAzure.ServiceRuntime | AzureCloudService - Error

Some assembly (.dll) file is missing when deployed in azure

Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 
Solution:
To fix the problem, add the following DLL's as references to "YourApplicationSolution" project, and make sure "Copy Local" is set to true.

Microsoft.WindowsAzure.Diagnostics
Microsoft.WindowsAzure.ServiceRuntime
Microsoft.WindowsAzure.StorageClient
You'll probably have to go to your application Bin folder to get the DLL's and put them back into your site's BIN folder.
Next, add all the DLLs as references and re-built the solution again.
OR
Expand the references section in Visual Studio and mark all the Azure DLLs as Copy Local = "True" - the Azure SDK DLLs need to be included in the bin directory they are not GACed.
If that fails, add an assembly binding redirect to the web.config...
<dependentAssembly> <assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly>