9

I have an application that references this assembly in development environments:

name="Microsoft.Data.SqlXml" culture="neutral" publicKeyToken="89845dcd8080cc91" version="9.0.242.0"

However, live server contains old version of this library:

name="Microsoft.Data.SqlXml" culture="neutral" publicKeyToken="b77a5c561934e089" version="3.2.2917.0"

As you see publicKeyToken is different. I've added bindingRedirect to app.config:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.Data.SqlXml" culture="neutral" publicKeyToken="89845dcd8080cc91" />
            <bindingRedirect oldVersion="9.0.242.0" newVersion="3.2.2917.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

but I still get the error:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass embly 'Microsoft.Data.SqlXml, Version=3.2.2917.0, Culture=neutral, PublicKeyToke n=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.Data.SqlXml, Version=3.2.2917.0, Culture=neutral, PublicKe yToken=89845dcd8080cc91' ---> System.IO.FileNotFoundException: Could not load fi le or assembly 'Microsoft.Data.SqlXml, Version=9.0.242.0, Culture=neutral, Publi cKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find t he file specified. File name: 'Microsoft.Data.SqlXml, Version=9.0.242.0, Culture=neutral, PublicKey Token=89845dcd8080cc91'

Is there any way to redirect to older version of library in that case?

dragonfly
  • 17,407
  • 30
  • 110
  • 219

1 Answers1

10

You can't redirect an assembly if the public key is different I am afraid, you will need to recompile against the older version and remove the redirect.

ChrisBint
  • 12,773
  • 6
  • 40
  • 62
  • Thanks, this is what I do on daily basis. I change reference to old assembly before making live release. It's a shame. Thanks. – dragonfly Oct 27 '11 at 08:48