We will take a look at various steps that we can take to figure out what is causing such errors and how to resolve them. In this article I will go through the steps of debugging the error that you see on the image above:
Could not load file or assembly 'Telerik.OpenAccess, Version=2016.1.224.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
If you are new to debugging such issues, it might be interesting to understand what the underlying cause is. Whenever your Sitefinity web app is starting, the runtime will try to load all referenced assemblies. In the case of Sitefinity, those are framework assemblies like System.Net.Http, Microsoft.CSharp, etc. and Sitefinity-specific ones like Telerik.Sitefinity.Frontend.
Of course, the process is more complex because all of the direct assembly references (like Telerik.Sitefinity.Frontend) have references of their own, and those must be resolved as well. Those "child" references are usually the cause of assembly binding problems.
Whenever the runtime is unable to find an assembly that out app is referencing, either directly or indirectly, it produces the beloved "Could not load file or assembly " error.
Let's now go back the error - "Could not load file or assembly 'Telerik.OpenAccess, Version=2016.1.224.1".
In the project, there is a reference to version 2016.2.822.1 (newer version) of that same assembly. Since we do not have a direct reference to version 2016.1.224.1 there must be an assembly reference that is requesting this specific earlier version by itself.
Before we take a look at how we can figure out which assembly is causing this problem, I would like to focus the attention to the official documentation on upgrading Sitefinity.
This should be enough to eliminate compile-time and run-time errors but once in a while you will stumble upon such errors and knowing how to debug them will come in handy.
Using Fusion Log to resolve assembly binding issuesFusion is the code name of the assembly loader in .NET. Fortunately, it comes with a logging mechanism. When enabled, it provides all the information you need to determine the exact cause.
All you need to do to enable logging is to set the HKLM\Software\Microsoft\Fusion\EnableLog registry value to 1. If you run your app, a more-detailed error message should be presented.
For this particular case, it was the Telerik.Sitefinity.MobileAppBuilder assembly that was responsible for the error. This particular assembly was a leftover from the previous version and should have been removed. As the case with Telerik.Sitefinity.MobileAppBuilder, Sitefinity might look for assemblies in the bin folder and try to load them, even if they are not explicitly added as project references.
Keep in mind that the logging functionality introduces a performance penalty and should be turned off after issues have been resolved.
This technique can be utilized to debug assembly binding problems for any .NET application, just take a look at Assembly Binding Log Viewer.