One of the nice features of Sharepoint 2010 is the automatic assemblies redirect which allows to use old code which was written and compiled for Sharepoint 2007 also in Sharepoint 2010. It is achieved by assemblies redirects in web.config. Let’s see what bindings are added when you create new web application:
Quite obvious. However it doesn’t contain bindings for 2 most frequently used assemblies:
Nevertheless these assemblies are also redirected from “22.214.171.124” version to “126.96.36.199” version. How Sharepoint performs this redirection, if there are no bindings in web.config file?
First of all why I’m sure that mentioned 2 assemblies are also redirected? Because our open source library Camlex.Net successfully works both in Sharepoint 2007 and Sharepoint 2010 without recompilations. It has reference to Microsoft.SharePoint.dll “188.8.131.52” version.
So there should be other way to achieve assembly binding redirection – which doesn’t rely on web.config. In order to investigate it I created simple application layouts page and added a call to Camlex method on it:
Before to access this page in context of Sharepoint 2010 site I ran fuslogvw.exe. It helped to get the answer. Here is the log:
Answer is on lines 26-27. Sharepoint uses publisher policy files technique in order to redirect binding of these assemblies. This is rarely used technique comparing with web.config modifications. I recommend the following article which gives the basic understanding how it works: Using publisher policy assemblies.
E.g. that’s how publisher policy file looks like for Microsoft.SharePoint.dll (as shown in log it is located in C:\Windows\assembly\GAC_MSIL\Policy.12.0.Microsoft.SharePoint\184.108.40.206__71e9bce111e9429c folder and has “Policy.12.0.Microsoft.SharePoint.config” name):
That’s how Sharepoint 2010 redirects assemblies binding from 2007 version.