Categories
Bloggers
Blogs RSS feed

Installing a different version of RadControls alongside Sitefinity

by Gabe Sumner

Yellow Screen of Death 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

The assembly references in a Sitefinity Web Project

3.  Select Telerik.Web.UI in the References list and press the Delete key

Removing the Telerik.Web.UI aseembly reference

4.  Select Telerik.Web.Design in the References list and press the Delete key

Removing the Telerik.Web.Design assembly reference

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

Adding assembly references to Telerik.Web.UI and Telerik.Web.Design

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.

6 comments

Leave a comment
  1. Scott Sep 13, 2010
    Gabe,

    Isn't this only possible if you're using a 'Web Application Project' instead of a 'Web Site Project'? I don't believe that option is available until Sitefinity 4.0, correct?

    It's good to know there's a solution for us in the future; I'm just making sure I'm not overlooking something while we continue to use 3.7.

    Thanks,

    Scott    
  2. Scott Sep 13, 2010
    Gabe,

    Isn't this only possible if you're using a 'Web Application Project' instead of a 'Web Site Project'? I don't believe that option is available until Sitefinity 4.0, correct?

    It's good to know there's a solution for us in the future; I'm just making sure I'm not overlooking something while we continue to use 3.7.

    Thanks,

    Scott    
  3. Scott Sep 13, 2010
    Gabe,

    Isn't this only possible if you're using a 'Web Application Project' instead of a 'Web Site Project'? I don't believe that option is available until Sitefinity 4.0, correct?

    It's good to know there's a solution for us in the future; I'm just making sure I'm not overlooking something while we continue to use 3.7.

    Thanks,

    Scott    
  4. Gabe Sumner Sep 17, 2010
    Hi Scott,

    You are correct.  Web site projects should automatically use whatever assembly (DLL) found in the ~/bin folder.
  5. Robert Mar 21, 2011
    The correct version is the old version. This does not explain how to use the newer version.
  6. Caleb Dec 17, 2012
    Hello Gabe. Would you know what version of Rad Controls work best with Sitefinity 5.0?   I've created a Rad Scheduler Widget and tied it into an SQL database. It works outside of Sitefinity, but when I load it up to Sitefinity as a custom widget, many of the buttons don't work and the advance schedule doesn't write to the database either.  

    But I know it works outside of Sitefinity, all of the functionality seems to be working fine.  So I was wondering if the Rad Controls version is incompatible with the version of Sitefinity I have. My current Rad Controls Telerik.Web.UI & the Design Dll files are on version 2012.1.215.40.  

    Caleb

    Leave a comment