Search code examples
.netdll.net-standardassembly-binding-redirect

Where is framework config for binding redirects?


My ASP.NET MVC web backend consumes System.Security.Cryptography.Algorithms.dll. On build, the dll is found in:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\Facades.

At runtime, the dll is resolved to:

C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Security.Cryptography.Algorithms\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Security.Cryptography.Algorithms.dll.

This is what fuslogvw shows:

...
LOG: Assembly download was successful. Attempting setup of file: path\to\bin\System.Security.Cryptography.Algorithms.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: System.Security.Cryptography.Algorithms, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: A partially-specified assembly bind succeeded from the application directory. Need to re-apply policy.
LOG: Using application configuration file: path\to\web.config
LOG: Using host configuration file: C:\Users\xxx\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Version redirect found in framework config: 4.2.2.0 redirected to 4.0.0.0.
LOG: Post-policy reference: System.Security.Cryptography.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Binding succeeds. Returns assembly from C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Security.Cryptography.Algorithms\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Security.Cryptography.Algorithms.dll.
LOG: Assembly is loaded in default load context.

I'm particularly interested in line LOG: Version redirect found in framework config: 4.2.2.0 redirected to 4.0.0.0.

Question:

Where is that framework config mentioned above? None of the three files mentioned in the log (web.config, machine.config, aspnet.config) contain a binding redirect directive for System.Security.Cryptography.Algorithms.dll, so where is it then?


Solution

  • The line you are seeing is coming from the unification table that is inside the runtime.

    The runtime has special knowledge of a handful of assemblies and for those is applies a special binding redirect if no user specified binding redirects are specified (in the locations you mentioned).