Error rendering control (Unable to cast object of TypeA to TypeA)

4 posts, 1 answers
  1. Answer
    Telerik Admin
    Telerik Admin avatar
    1629 posts
    Member since:
    Oct 2004

    Posted 28 Jul 2010 Link to this post

    Hi all,

    Recently we discovered that Visual Studio can sporadicaly display the "Error rendering control" message in design time.
    This can occur in several specific error messages:
    • [A]Telerik.Web.UI.RadScriptManager cannot be cast to [B]Telerik.Web.UI.RadScriptManager. Type A originates from...
    • Unable to cast object of type 'Telerik.Web.UI.RadScriptManager' to 'Telerik.Web.UI.RadScriptManager'
    • Unable to cast object of type Telerik.Web.UI.[ControlName] to Telerik.Web.UI.ControlItemContainer

    The screenshots below demonstrate sample occurrences of the error:

    A subsequent close of the page in design time and a further reload usually might make it render correctly. A further close and reload can cause the error to reappear though.

    Our research showed that some registry entries we use to enable Visual Studio display RadControls in the "Add Reference" and "Choose ToolBox Items" dialogs are the reason for the error. It seems that for some reason Visual Studio loads several instances of the Telerik.Web.UI assembly into its AppDomain, which results in the error above.
    We decided to sacrifice the appearance of the Telerik.Web.UI assembly in the above mentioned dialogs, but prevent this annoying error from happening and we already removed the registry entries from the RadControls installers.

    As a fix in the meantime, you could use the .reg files in the attached archives (one targets a 32-bit machine and the other targets a 64-bit one) and the .bat files (targeting Windows XP and Windows7/Vista respectively) to fix the problem. Here are the steps to follow:
    1. Download and extract the archive to a folder of your choice
    2. Close all Visual Studio instances
    3. Double-click the .reg file (use the Remove_AssemblyFoldersEx_32bitMachine.reg for 32-bit machines and the  Remove_AssemblyFoldersEx_64bitMachine.reg one for 64-bit machines) and click the 'Yes' button when asked to confirm the registry entry merge
    4. Double-click the bat file, depending on the Windows system you're running (use the ClearProjectAssemblies_Win7_Vista.bat for Windows7/Vista and the ClearProjectAssemblies_WinXP.bat for Windows XP)
    5. Start Visual Studio and load your project

    Kind regards,
    Erjan Gavalji
  2. SorinC
    SorinC avatar
    11 posts
    Member since:
    Nov 2009

    Posted 23 Mar 2011 Link to this post

    Hi all,

    Quite recently I converted a web site to a web application after upgrading to the latest Telerik Ajax package (Q3 2010). Subsequently, I noticed rendering and/or creating control errors on aspx pages at design time on several development machines. After trying the frequently suggested fix of clearing assembly caches to no avail, I came across a post regarding the Toolbox. I noticed that none of the Rad controls were visible in the Toolbox. Connecting the dots, I realized that the wrong version of controls were installed (could be due to the fact that higher versions of the Framework were installed on the machine and the setup assumed the higher version is used for development)

    My development machine configuration:
    • XP 32 bit
    • Visual Studio 2008
    • Using Microsoft.Net v2.0.50727 (with 3, 3.5 and 4 installed on the machine)
    • RadControls for ASP.NET AJAX Q3 2010


    Here are the steps to fix the problem:
    1. Right-click on the Toolbox and select Choose Items...
    2. Click on the header reading Assembly Name to sort by this column
    3. Scroll up/down until you see Telerik.Web.UI in the column
    4. Expand the column to be able to read the version at the right 
    If all you see see is 2010.3.1317.35, this is your problem. To fix it:
    5. Select all rows in the dialog having this version, then press the space bar. This should deselect all 3.5 controls
    6. Click Browse and navigate to the Telerik installation (Typically C:\Program Files\Telerik\RadControls for ASP.NET AJAX Q3 2010\Bin20)
    7. Select Telerik.Web.UI.dll and click Open
    The toolbox should load all the Rad controls for version 2.0.-- it may take a few good seconds
    If you still see errors in design:
    8. Click on View | Refresh to re-render the page. The errors shouldn't be there anymore

    Hope this will help anyone who has the problem..
  3. Shweta
    Shweta avatar
    1 posts
    Member since:
    Jan 2013

    Posted 19 Jan 2013 Link to this post

     getting this error

    Duplicate component name 'RadGrid1'. Component names must be unique and case-insensitive.
  4. Nicklas
    Nicklas avatar
    16 posts
    Member since:
    Mar 2012

    Posted 05 Aug 2013 Link to this post

    Thanks worked out fine, been struggling with this for the past hour. 
Back to Top