Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BindingRedirect not being honored within cloud service

I'm receiving an exception when initializing a cloud service:

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Understanding that I have version 4.3.0.0 installed, I have added the following redirect into the app.config for my worker:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>

When run locally within the local emulator this resolves the issue. When this is packaged through cspack the app.config and worker.dll.config are included in the package.xml, both have the binding redirect included. The 'Microsoft.WindowsAzure.Storage' is also included, both the .dll and .xml.

So as far as I see it, everything that is required during runtime has been supplied.

Unfortunately, the exception is telling me that the redirect has not been applied and it is still looking for version 2.1.0.0. Am I doing something wrong here?

like image 647
herecydev Avatar asked Apr 29 '15 12:04

herecydev


People also ask

What is bindingRedirect in web config?

To redirect one assembly version to another, use the <bindingRedirect> element. The oldVersion attribute can specify a single assembly version or a range of versions. The newVersion attribute should specify a single version. For example, <bindingRedirect oldVersion="1.1.

How do I enable and disable automatic binding redirection?

Right-click the project in Solution Explorer and select Properties. On the Application page, uncheck the Auto-generate binding redirects option. If you don't see the option, you'll need to manually disable the feature in the project file.


1 Answers

Add a file named after your project so it'll match the name of the assembly.

{ProjectName}.dll.config with Copy to Output Directory = Always and Build action = None

This file has the same syntax as your app.config. It should contains your assembly bindings.

For some reason, the file generated from app.config is not included in the deployment package.

like image 133
Guillaume Avatar answered Oct 17 '22 12:10

Guillaume