0

I have a ASP.NET legacy project to which ADFS authentication needs to be added. So I did the same but when I run the application, I keep getting this error:

Could not load file or assembly 'Microsoft.IdentityModel.Protocols.WsFederation, Version=5.2.0.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)

Here is my web.config entry for the said assembly

<dependentAssembly>
    <assemblyIdentity name="Microsoft.IdentityModel.Protocols.WsFederation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" />
</dependentAssembly>

and my packages.json entry

 <package id="Microsoft.IdentityModel.Protocols.WsFederation" version="5.3.0" targetFramework="net452"/>

Why does the solution still search for version 5.2.0 when I refer to version 5.3.0?

Lorenzo Isidori
  • 1,809
  • 2
  • 20
  • 31
  • Try removing the `bindingRedirect` entry; that can sometimes confuse things. (From personal experience) – Peter Smith Nov 21 '19 at 09:07
  • Did not help, however thanks for the suggestion –  Nov 21 '19 at 09:15
  • I think you should provide more detials: target framework, if error happens in both debug or release mode, maybe you can share your csproj showing us the references... – Lorenzo Isidori Nov 21 '19 at 14:12
  • Target framework is 4.5.2, happens in debug mode. Project is of asp.net template and doesn't have .csproj file –  Nov 22 '19 at 06:07
  • Issue is resolved after i updated this specific nuget package and its dependencies and downgraded to 5.3 as per the suggestion from the error . –  Dec 02 '19 at 11:28

1 Answers1

0

Check if the Top <Configuration> tag has this attribute

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

If you do, you will need to remove this in order for the BindingRedirect to work. More info here https://stackoverflow.com/a/37722093/1628611

Manish Pradhan
  • 1,141
  • 10
  • 28