You have an Desktop Application that was built for SharePoint 2010 and you need to run in on SharePoint 2013. When the Application is ran the following error is displayed, System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SharePoint, Version=18.104.22.168, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
- Assembly Version
- SharePoint 2013 doesn’t come with version 14 (2010) or 12 (2007) assemblies.
- For backwards compatibility, SharePoint deploys Assembly Binding Redirects for previous assembly versions, what this does is redirect any calls to version 12 or 14 to the version 15 of the assembly.
- Here is an example of the Assembly Binding Redirect Configuration:
<assemblyIdentity name="Microsoft.SharePoint" publicKeyToken="71e9bce111e9429c" culture="neutral" />
<!-- Redirecting to version 22.214.171.124 of the assembly. -->
<bindingRedirect oldVersion="126.96.36.199" newVersion="188.8.131.52" />
- Common Language Runtime Version
- At this point you're thinking, since we have Assembly Binding Redirects, then our Application should work!
- The issue is that SharePoint 2010 Applications are written in .Net 3.5, while SharePoint 2013 is written in .Net 4.5
- .Net 4.0 introduced a new version of the CLR (Common Language Runtime), it is essentially what runs .Net code
- Due to the CLR update, it is not possible to load .Net 4.5 assemblies from .NET 3.5, however the other way works fine.
- .Net Supports a notion of a Configuration file for executables. This configuration allows you to change the way the application is ran, among many other things.
- More info:
- To fix our issue, we are going to tell .NET to use the 4.0 CLR, which is what .Net 4.5 uses.
- Assuming our application is called MyApp.exe, create a text file called MyApp.exe.config and place the following XML into it:
- <?xml version="1.0" encoding="utf-8"?>
- Now when you run your application, it will use the 4.0 CLR and the application should work correctly with SharePoint 2013.