none
"bindingRedirect" in web.config does not work (but in machine.config is does)

    Question

  • Hello everybody,

    I'm using the "bindingRedirect" element in my web.config to allow updates of my referenced assembly without recompiling my website. But I still receive the same error:

    Could not load file or assembly 'TestLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c417d4d39ba0d6b2' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    I built my website with version 1.0.0.0 of "TestLibrary". After that I created a version 1.1.0.0 of "TestLibrary" which I placed in the "bin" folder of my website. When accessing the website, the error above is shown.

    I read that it's possible to redirect assemblies to newer versions with the "bindingRedirect" element in the web.config. My web.config looks like this:

      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="TestLibrary" publicKeyToken="c417d4d39ba0d6b2" culture="neutral" />
              <bindingRedirect oldVersion="1.0.0.0" newVersion="1.1.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>

    But even with that element, the error is still shown!

    However, when I place the same XML in the "machine.config", my website works just fine. But I do not want to alter the "machine.config" if it isn't necessary.

    Btw: If I place the old and the new assembly in the GAC, the website is always using the old version, even if I use the "bindingRedirect" trick.

    Does anybody know a solution for my problem?

    Thursday, August 10, 2006 2:50 PM

Answers

  • Hey Bastiaan

    I had the exact same problem, and after a couple of days trying to fix it, i found a really simple solution

    it's this line:

    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

    at the beginning of the web.config

    .NET automatically creates the xmlns tag and sets it to http://schemas.microsoft.com/.NetConfiguration/v2.0, apparently this is what was causing the problem in my application, i removed the xmlns tag, i.e. I had it written as:

    <configuration>

    and everything worked great, try it, and please tell me how it goes!

    Wednesday, March 05, 2008 8:53 AM

All replies

  • Nobody?
    Wednesday, August 30, 2006 11:42 AM
  • What I've tried and works on .NET 2.0. Use fuslovw.exe to see what's happening. 

    <runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

    <dependentAssembly>

    <assemblyIdentity name="System.Web.Services" publicKeyToken="b03f5f7f11d50a3a" />

    <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />

    </dependentAssembly>

    </assemblyBinding>

    </runtime>

    Wednesday, August 30, 2006 12:24 PM
  • The Assembly Binding Log Viewer (Fuslogvw.exe) remains empty. There are no items shown in the viewer, even after several refreshes or restarts of IIS or my web-application. (Maybe that's the problem?)
    Thursday, August 31, 2006 9:14 AM
  • Try to use a custom log location.
    Thursday, August 31, 2006 1:45 PM
  • That doesn't help. The viewer remains empty. :-(
    Thursday, August 31, 2006 2:20 PM
  • Hi,

    unfortunately I just can confirm, that this problem does not affect only your machine. It's also happening on a couple of developer machines at our site. And no solution at hand :-(((

    Does really nobody else experience this?

    -Erich


    Sunday, February 11, 2007 5:01 PM
  • Hi,

    in FusLogVw / Settings you must select one of the 2 options "Log ... to disk" and enter a custom log path to make it work.

    -Erich

    Sunday, February 11, 2007 5:05 PM
  • Hey Bastiaan

    I had the exact same problem, and after a couple of days trying to fix it, i found a really simple solution

    it's this line:

    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

    at the beginning of the web.config

    .NET automatically creates the xmlns tag and sets it to http://schemas.microsoft.com/.NetConfiguration/v2.0, apparently this is what was causing the problem in my application, i removed the xmlns tag, i.e. I had it written as:

    <configuration>

    and everything worked great, try it, and please tell me how it goes!

    Wednesday, March 05, 2008 8:53 AM
  • I had the same problem on my WebApp.

    Removing the xmlns tag, was the solution!!!

    Thanks Mohamed

    Tuesday, October 07, 2008 1:13 PM
  • I still got the same problem and removing the xmlns attribute in the configuration element does not resolve it (I'm referring to the FileLoadException).

    - In my case I'm having a code HRESULT: 0x80131040.
    - I'm using two libraries in my webapp that are referencing different versions of AjaxControlToolkit.

    Please, any other workaround found?

    thks
    Wednesday, February 18, 2009 5:52 PM
  • Wow - how did you find this? I've been trying to solve this same issue for quite some time.

    So stupid that xmlns would prevent binding redirect from working properly, so angry right now...

    Thursday, July 12, 2012 2:34 AM