This is a migrated thread and some comments may be shown as answers.

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

0 Answers 241 Views
Installer and VS Extensions
This is a migrated thread and some comments may be shown as answers.
Telerik Admin
Top achievements
Rank 1
Telerik Admin asked on 28 Jul 2010, 03:07 PM
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
Telerik

No answers yet. Maybe you can help?

Tags
Installer and VS Extensions
Asked by
Telerik Admin
Top achievements
Rank 1
Share this question
or