.Net Assembly Binding Redirect doesn’t work – because you have an Uppercase/lowercase error in config

Thanks to Eran Stiller for spotting the fact that assembly binding redirect fails—with no appropriate error message or clue as to the reason for failure—if you used PascalCasing instead of camelCasing casing in your config.
This fails:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Moq" Culture="neutral" PublicKeyToken="69f491c39445e920" />
        <bindingRedirect oldVersion="4.0.10827.0" newVersion="4.1.1309.1617" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

because of incorrect case in the attributes Culture and PublicKeyToken. Make them camelCase like so:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Moq" culture="neutral" publicKeyToken="69f491c39445e920" />
        <bindingRedirect oldVersion="4.0.10827.0" newVersion="4.1.1309.1617" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

and now it works.

Leave a Reply

Your email address will not be published. Required fields are marked *