'Could not load file or assembly 'Microsoft.IdentityModel.Protocols.WsFederation

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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Manish Pradhan