Azure Deployment Issue: Unhandled Exception: Could not load file or assembly 'Microsoft.Azure.DocumentDB.Core

1

I was having performance issues with table storage and upgraded to the latest library/sdk. Everything works fine locally and I can run on the emulator. However, when I try to deploy to my Azure Cloud Service I get the following error:

Details: Recovering role... Unhandled Exception: Could not load file or assembly 'Microsoft.Azure.DocumentDB.Core, Version=2.11.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The web role just recycles constantly with this error. The actual dll version is 2.11.6.0. Things I have tried:

  1. I have logged on to the web role and checked the dll is the expected one (2.11.6.0).
  2. bindingRedirects: all relevant projects have a binding redirect of this form:
<dependentAssembly>
    <assemblyIdentity name="Microsoft.Azure.DocumentDB.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.11.6.0" newVersion="2.11.6.0" />
  </dependentAssembly>
  1. I have done a text search through all files in my project for Microsoft.Azure.DocumentDB.Core - every reference (that mentions version) references 2.11.6.0. This includes files of this form dll.config file - which I did not manually edit but which do have the correct redirect.
  2. I tried changing the Azure role osFamily to 6 (it had been 5)
  3. I tried deleting the packages folder and regenerating
  4. I tried deleting all redirect statements and allowing Visual Studio to automatically generate them for me.

The publish is done via 'publish' in Visual Studio 2019 on the Cloud Service (csdef).

Could anyone suggest what else I can try to deploy this cloud service?

azure
deployment
cloud
assemblies
asked on Stack Overflow Sep 8, 2020 by Rob Wavre

1 Answer

0

Eventually found a way round this. So, when run locally a file WebRoleName.dll.config is produced alongside the web.config. This file is not deployed. The content is an exact copy of the web.config file. All its settings are ignored apart from the redirects. The redirects are used, seemingly, just while the web role is being started up. So, I added the file based on my local configuration (so completely the wrong database settings, etc.) to the root of my Web Role project and set it to Content - Copy Always.

Now everything runs OK - obviously it would be better if this generated file was deployed by the Visual Studio Azure publish automatically.

answered on Stack Overflow Oct 29, 2020 by Rob Wavre

User contributions licensed under CC BY-SA 3.0