| Sep 01, 2010
Because of my role with Telerik I’m constantly installing internal builds or random versions of our products. Consequently, I’ve seen the following error a lot:
Could not load file or assembly 'Telerik.Web.UI, Version=2010.1.309.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
This error means I’ve installed a different version of RadControls than Sitefinity is expecting.
The reason this happens is because the file path to the Telerik.Web.UI assemblies isn’t explicitly set in the Sitefinity project. Because no explicit location is specified, Visual Studio looks for (and finds) this assembly in the GAC. Unfortunately, the version found is different than the version required by Sitefinity. During the build process, Visual Studio copies this incorrect version into the ~/bin folder and overwrites the correct version. This leaves me with a broken project. :(
This blog post describes how to prevent and repair this damage.
Get the correct Sitefinity RadControls DLL
The first step is to repair the damage done by the build. As mentioned, during the build process Visual Studio will overwrite Sitefinity’s Telerik.Web.UI assemblies with the version of RadControls installed on your computer. Before Sitefinity can be made to work, this needs undone.
To fix this:
1. Find the correct version of the Telerik.Web.UI.dll and Telerik.Web.Design.dll files
2. Copy these files into the ~/bin folder of the broken Sitefinity web site (overwriting the incorrect versions).
Hopefully a backup of your web site is available. The DLL files can be copied from this backup. If not, download Sitefinity (the same version the broken web site is using) and copy the DLL file included in a fresh Sitefinity project into the project’s ~/bin folder.
Set an explicit path to the Telerik.Web.UI assemblies
Sitefinity now has access to the correct version of the Telerik.Web.UI assemblies. The next step is to prevent this from happening again. To do this, Visual Studio needs instructed to use the assemblies in ~/bin, not the assemblies found in the GAC.
To do this:
1. Open the web site (or web application) project in Visual Studio.
2. Expand the References folder in the Solution Explorer
3. Select Telerik.Web.UI in the References list and press the Delete key
4. Select Telerik.Web.Design in the References list and press the Delete key
5. Right-click the Reference folder and click Add Reference
6. Click the Browse tab
7. Browse to the ~/bin folder
8. Hold the Control key and select Telerik.Web.Design.dll and Telerik.Web.UI.dll
9. Click the OK button
Finished, but what about upgrading RadControls?
That’s it. The project can now be built and run. Sitefinity will continue to use the correct versions of the Telerik.Web.UI assemblies. RadControls can be upgraded or uninstalled from your computer and this Sitefinity project will not be impacted.
By the way, if your aim was to upgrade the version of RadControls used by Sitefinity, this is not possible. The Sitefinity team typically includes the latest versions of RadControls in Sitefinity Service Packs. These Service Packs are made available a few weeks after the official RadControls release. It is recommended that you wait for the Sitefinity team to officially support and include RadControl updates in Sitefinity Services Packs.
This being said, if you want to tempt fate, you might be able to use assembly redirects to convince Sitefinity to work with a different version of RadControls. I don’t recommend it though.