Problem: Could not load assembly reference
Sitefinity CMS ships with an updated reference to System.Web.OData. This updated reference has a chain of dependent references that get added when you use the NuGet package. When using Visual Studio versions 15.8.0 and newer, Visual Studio automatically adds assembly binding redirect for the following assemblies:
System.LinqSystem.Linq.ExpressionsSystem.ReflectionSystem.Runtime.Extensions
It redirects them to .NET Framework version 4.8. Because Sitefinity CMS is built with .NET Framework 4.8, on runtime you get the assembly reference error.
The exception occurs in the following format: Could not load a reference assembly for execution.
Solution 1: Fix the incorrectly introduced binding redirects
- Remove the assembly binding redirects in your
web.configfile for the following assemblies:
System.LinqSystem.Linq.ExpressionsSystem.ReflectionSystem.Runtime.Extensions
-
Save the
web.configfile and run your project. -
(Optional) Delete the incorrectly added assemblies.
Although they will no longer cause any issues, you can also manually delete the assemblies targeting .NET Framework version 4.8 from your Sitefinity CMS projectbinfolder. When you rebuild your project, the assemblies will no longer be available in thebinfolder.
Solution 2: Upgrade your Visual Studio version
Use Visual Studio version 2019 or newer.