Menu problem: 'Error Creating Control' at design time

13 posts, 1 answers
  1. Rob
    Rob avatar
    23 posts
    Member since:
    Jul 2008

    Posted 27 Aug 2008 Link to this post

    Something strange is happening with a RadMenu control on my page that was previously working just fine.

    Here's my menu code:

    <telerik:RadMenu ID="RadMenu1"   
                     Runat="server"   
                     Skin="Web20_PL"   
                     EnableEmbeddedSkins="False"   
                     CssClass="MasterMenu"   
                     ForeColor="#467464">  
                     <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                     <Items> 
                       <telerik:RadMenuItem runat="server"   
                                            NavigateUrl="Default.aspx"   
                                            Text="Home"   
                                            ForeColor="#467464">  
                       </telerik:RadMenuItem> 
                       <telerik:RadMenuItem runat="server"   
                                            NavigateUrl="Exposure.aspx"   
                                            Text="Exposure"   
                                            AccessKey="E" 
                                            ForeColor="#467464">  
                       </telerik:RadMenuItem> 
                       <telerik:RadMenuItem runat="server"   
                                            Text="Cash"   
                                            ForeColor="#467464" 
                                            AccessKey="C">  
                                  <Items> 
                                    <telerik:RadMenuItem runat="server"   
                                                         NavigateUrl="CashSummary.aspx" 
                                                         Text="Summary" 
                                                         AccessKey="S">  
                                    </telerik:RadMenuItem> 
                                    <telerik:RadMenuItem runat="server"   
                                                         NavigateUrl="CashAuthorisation.aspx"   
                                                         Text="Authorisation" 
                                                         AccessKey="A">  
                                    </telerik:RadMenuItem> 
                                  </Items> 
                       </telerik:RadMenuItem> 
                     </Items> 
    </telerik:RadMenu> 
              
     

    At design time the menu, which previously was looking just fine, is now replaced with a glyph that contains the following message:

    Error Creating Control - RadMenu1

    'Items' could not be initialized.   
    Details:   
    Unable to cast object of type 'Telerik.Web.UI.RadMenuItemCollection' to type   
    'Telerik.Web.UI.RadMenuItemCollection'.<BR> 

    Very strange, because the menu works at run time.

    Any thoughts?
  2. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 27 Aug 2008 Link to this post

    Hello Rob,

    Here is an extract from our General Troubleshooting section:

    Problem:

    Design-Time error on a page using RadControl(s):

    Error Creating Control - RadControl
    'Property' cannot be initialized. Details: Unable to cast object of type 'Type' to type 'Type'.

    Cause:

    If the Telerik.Web.UI.dll assembly is updated while a page using RadControl(s) is in Design-Time, VisualStudio creates two different versions of the assembly, hence two different versions of the same RadControl(s) are available.

    Suggested solution:

    Restart Visual Studio.

    I hope this helps.

    Greetings,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rob
    Rob avatar
    23 posts
    Member since:
    Jul 2008

    Posted 27 Aug 2008 Link to this post

    If the Telerik.Web.UI.dll assembly is updated while a page using RadControl(s) is in Design-Time, VisualStudio creates two different versions of the assembly

    Thanks for the quick reply Veskoni - restarting Visual Studio did indeed solve the problem.

    I'm curious though - can you clarify what you mean by the assembly being 'updated' while the page is in design mode. What kind of update are you referring to, and what causes it?

  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 27 Aug 2008 Link to this post

    Hello Rob,

    When VS is in design mode - the Telerik.Web.UI.dll is loaded. Then if the user replaces the dll by either copying it in the bin folder or dragging and dropping a new control (from different assembly) in the design surface - VS loads the updated assembly.

    You can also check this article:
    http://blogs.microsoft.co.il/blogs/kolbis/archive/2008/06/29/unable-to-cast-object-from-type-x-to-type-x.aspx

    All the best,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Todd
    Todd avatar
    3 posts
    Member since:
    Sep 2008

    Posted 19 Dec 2008 Link to this post

    What seems to have fixed it for me was in my web.config file, removing the specific version, Culture, and PublicKeyToken from the Telerik.Web.UI.WebResource.axd entry.

    Example broken:
    <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.2.826.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false" /> 


    Example fixed:
    <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false" /> 

  7. Tony Vainikos
    Tony Vainikos avatar
    58 posts
    Member since:
    Jan 2009

    Posted 11 May 2009 Link to this post

    Todd, I cannot see what changes you made in your web.config file to help fix this problem. I'm encountering the same thing in VS2008 when trying to add a combo box. I've tried restarting, deleting the folders as the blog indicated that Veskoni referenced, and nothing is working. Wierd thing is I can work with it in source view and if I pop over from source view with the combo box selected, I can see the properties in the property window, until I deselect it. Then of course, cannot select it again in design view. I'm only encountering this in VS2008, before the upgrade all was well.

  8. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 12 May 2009 Link to this post

    Hi TONY VAINIKOS,

    I suggest you check this blog post which explains the reason for this error and proposes three solutions.

    Sincerely yours,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Tony Vainikos
    Tony Vainikos avatar
    58 posts
    Member since:
    Jan 2009

    Posted 13 May 2009 Link to this post

    Ok I tried everything in the blog but nothing seemed to work. But it got me to thinking that perhaps when I installed VS2008 something might not have been carried over. Here was my situation, for those that might experience the same thing as I did. I was using VS2005 and had installed the latest ASP.NET AJAX UI Controls 2009. Well I then installed VS2009 sometime afterwards, but when I tried to load certain controls in design-view it gave me the error I spoke of in my earlier posts. However, in source-view I could configure the control and everything seemed to work when I viewed the page on my server.

    So how did I fix this problem. I uninstalled the ASP.NET AJAX UI Control 2009, and also realized I hadn't uninstalled the previous version, so uninstalled that one too. Then re-installed the ASP.NET AJAX UI Control 2009. I think this time, since VS2008 was already on my system, it installed the necessary components accessible by 2008. Now everything is fine in my programming paradise!
  10. Mark Meikle
    Mark Meikle avatar
    16 posts
    Member since:
    Mar 2010

    Posted 10 Feb 2011 Link to this post

    I have tried everything on this thread and on the blog and cannot resolve this problem.  Any other solutions at all?  Will reinstalling VS2010 help?
  11. Mark Meikle
    Mark Meikle avatar
    16 posts
    Member since:
    Mar 2010

    Posted 10 Feb 2011 Link to this post

    After months of bearing the annoyance of this issue (it only applied to some of my controls), today it blossomed and happened with all my controls.  I spent 4 hours pouring over the forums and trying everything.  Here's what I learned:

    I'm using Visual Web Developer Express Edition 10.0

    I tried everything on this post, including blog solutions, to no avail.  Tried reinstalling VWDE10 to no avail.  Tried reinstalling RadControls no avail.

    Then, here's my episode to get things working...
    ------------------------------------------------------------------------------------------------------

    Finally got an error that helped me find my solution:
    System.InvalidCastException: [A]Telerik.Web.UI.RadGrid cannot be cast to [B]Telerik.Web.UI.RadGrid.  Type A originates from 'Telerik.Web.UI, Version=2010.1.519.35...' at location 'C:\Users\Mark\AppData\Local\Microsoft\VWDExpress\10.0\ProjectAssemblies\eo8jjiae01\Telerik.Web.UI.dll'  , and B) is located at C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies

    I erased the DLL at "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies" and restarted VWD.

    Everything worked.

    Tried to add a rad control from my toolbox and...

    Got similar error again only slightly different:
    System.InvalidCastException: [A]Telerik.Web.UI.RadGrid cannot be cast to [B]Telerik.Web.UI.RadGrid.  Type A originates from 'Telerik.Web.UI, Version=2010.1.519.35...' at location 'C:\Users\Mark\AppData\Local\Microsoft\VWDExpress\10.0\ProjectAssemblies\eo8jjiae01\Telerik.Web.UI.dll', and B) is located at 'C:\Users\Mark\AppData\Local\Microsoft\VWDExpress\10.0\ProjectAssemblies\qgrgfrem01\Telerik.Web.UI.dll'

    I noticed that the control I added from the toolbox was a version .35 control (after clicking 'Choose Items' on toolbox).  That placed a version .35 DLL in that 'C:\Users\Mark\AppData\Local\Microsoft\VWDExpress\10.0\ProjectAssemblies\qgrgfrem01\Telerik.Web.UI.dll' folder and triggered the errors and confusion once again.

    In the end I have decided to keep only version .20 controls in my toolbox and this seems to work.

    Here's the final configuration that works for me:

    Config file:
    ------------------------------------------------------------------------------------------------------

    <httpHandlers>
        <add verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler, Telerik.Web.UI" validate="false"/>
        <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false"/>
        <add path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Version=2010.1.519.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>
    </httpHandlers>

    <assemblies>
        <add assembly="Telerik.Web.Design, Version=2010.1.519.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
    </assemblies>


    - One strange thing to me is that I can change the version to 519.40 or 519.20 in the spellcheckhandler line and not notice any difference - yet.
    - At first I had the code read:
    <assemblies>
        <add assembly="Telerik.Web.Design, Culture=neutral"/>
    </assemblies>
    But upon compilation, it griped that it couldn't find the file.
    So changed it to this and it worked:
    <assemblies>
        <add assembly="Telerik.Web.Design, Version=2010.1.519.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4"/>
    </assemblies>

    DLLs
    ------------------------------------------------------------------------------------------------------
    Version 2010.1.519.20 at
    C:\Users\Mark\AppData\Local\Microsoft\VWDExpress\10.0\ProjectAssemblies\qgrgfrem01\Telerik.Web.UI.dll

    - Having DLLs in Bin or not does not seem to matter.  VS seems to add this file to my bin automatically at it's discretion.
    - NO DLL in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies


    c:\Windows\Assembly
    ------------------------------------------------------------------------------------------------------
    Still have
    Telerik.Web.Design 2010.1.519.35
    Telerik.Web.Design 2010.1.519.20

    -Hopefully having both doesn't cause problems.  Can't delete them.


    One final note, kind of for me and you too:

    - For a long time, most of my radcontrols showed fine in the development environment, but some did not, and gave a similar error.  I think this happened because my solution uses controls from older versions and the newer versions.  I'm now guessing this is not a good idea, although it seems strange.  You'd think Telerik would want us to upgrade.  I'm guessing there's something about upgrading that I just don't understand or maybe some kinks they need to work out.  Regardless, now, with the version .20 DLL in place, and using only version .20 controls in my toolbox all the controls seem to work properly.
  12. Erjan Gavalji
    Admin
    Erjan Gavalji avatar
    1455 posts

    Posted 11 Feb 2011 Link to this post

    Hi Mark,

    Sorry for the troubles and good to know you have them sorted out now.

    I just wanted to add a clarification on having different versions of the Telerik.Web.UI assembly in different projects under the same solution: Visual Studio runs under a single AppDoman. Due to the .NET Framework specifics, when there are two instances of the same namespace/class name in the same AppDomain, the environment can't properly resolve the type to load. Thus, an InvalidCastException gets thrown when a type in one of the assemblies tries using a type from the other assembly.

    Kind regards,
    Erjan Gavalji
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  13. Korgman
    Korgman avatar
    3 posts
    Member since:
    Jan 2011

    Posted 10 Aug 2012 Link to this post

    Yes, but you never told him how to AVOID these problems in the first place! :-(

    I've had horrendous problems with upgrading a large ASP.NET AJAX project again this week - DevExpress seems to have solved it for their controls.  Why can't Telerik?  I've reported the upgrading problems multiple times this week, and still no answer with a REAL solution.

    Your upgrade Wizard in VS2010 is also faulty - often it doesn't recognise the use of Telerik.WEB.UI in my C# libraries - only in the main application. If you must spread the assemblies over the disk, can the installer not at least be sure to remove everything before it starts upgrading?

    It remains a real hassle, expecially when you want to keep up to date with things and ESPECIALLY when the only thing to resolve a problem is the nightly builds.  Why can't you publish a script or a DIY list of all things you need to do to avoid these problems?

    Can you please either fix it, or tell me EXACTLY what to do to avoid these problems - I've lost at least 1.5 days work this week...

    Barry
  14. Petar
    Admin
    Petar avatar
    219 posts

    Posted 15 Aug 2012 Link to this post

    Hi Barry,

    I am really sorry that the automatic upgrade wizard caused troubles on your side. I think t it is due to some specific configuration of your projects.

    We have online article giving a step by step instructions about how to upgrade to a different version of the RadControls - http://www.telerik.com/help/aspnet-ajax/introduction-upgrading.html.

    I hope it helps.

    All the best,
    Petar
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017