ArgumentNullException thrown in RouteCollection.SetItem

5 posts, 0 answers
  1. Andrew
    Andrew avatar
    34 posts
    Member since:
    Dec 2010

    Posted 06 Mar 2013 Link to this post

    I converted my WebForms application to a web application, but now I am unable to use the Kendo ASP.NET MVC widgets.

    I have tried to code examples, and both cause ArgumentNullExceptions to be thrown in System.Web.Routing.RouteCollection.

    Here are two examples:

    @(Html.Kendo().Menu().Name("menu").Items(menuItemFactory => { menuItemFactory.Add().Text("Menu Item"); }))

    Results in this exception:

    [ArgumentNullException: Value cannot be null.
    Parameter name: item]
       System.Web.Routing.RouteCollection.SetItem(Int32 index, RouteBase item) +2340263
       System.Collections.ObjectModel.Collection`1.set_Item(Int32 index, T value) +116
       Kendo.Mvc.UI.NavigatableExtensions.IsCurrent(INavigatable navigatable, ViewContext viewContext, IUrlGenerator urlGenerator) +69
       Kendo.Mvc.UI.Menu.HighlightSelectedItem(MenuItem item) +86
       Kendo.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) +194
       Kendo.Mvc.UI.Menu.WriteHtml(HtmlTextWriter writer) +202
       Kendo.Mvc.UI.WidgetBase.ToHtmlString() +115
       Kendo.Mvc.UI.Fluent.WidgetBuilderBase`2.ToHtmlString() +62
       System.Web.HttpUtility.HtmlEncode(Object value) +38
       System.Web.WebPages.WebPageBase.Write(Object value) +68
       ASP._Page_Views_PlayerGroup_ScreenLayout_cshtml.Execute() in c:\Development\Development\c#\Clients\DAT Media\CMS\CMS.Website\Views\PlayerGroup\ScreenLayout.cshtml:15
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
    


    Similarly, calling the TabStrip code:

    @(Html.Kendo().TabStrip()
                .Name("tabStrip")
                .Items(tabStrip =>
                    {
                        tabStrip.Add().Text("First").Content("First tab strip content");
                        tabStrip.Add().Text("Second").Content("Second tab strip content");
                    }
                    )
                    )



    Results in the same exception. (The only difference it that it's TabStrip.WriteHtml instead of Menu.WriteHtml)

    [ArgumentNullException: Value cannot be null.
    Parameter name: item]
       System.Web.Routing.RouteCollection.SetItem(Int32 index, RouteBase item) +2340263
       System.Collections.ObjectModel.Collection`1.set_Item(Int32 index, T value) +116
       Kendo.Mvc.UI.NavigatableExtensions.IsCurrent(INavigatable navigatable, ViewContext viewContext, IUrlGenerator urlGenerator) +69
       Kendo.Mvc.UI.TabStrip.HighlightSelectedItem(TabStripItem item) +80
       Kendo.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) +194
       Kendo.Mvc.UI.TabStrip.WriteHtml(HtmlTextWriter writer) +294
       Kendo.Mvc.UI.WidgetBase.ToHtmlString() +115
       Kendo.Mvc.UI.Fluent.WidgetBuilderBase`2.ToHtmlString() +62
       System.Web.HttpUtility.HtmlEncode(Object value) +38
       System.Web.WebPages.WebPageBase.Write(Object value) +68
       ASP._Page_Views_PlayerGroup_ScreenLayout_cshtml.Execute() in c:\Development\Development\c#\Clients\DAT Media\CMS\CMS.Website\Views\PlayerGroup\ScreenLayout.cshtml:15
    


    I have also created a new project using the "Kendo UI for MVC Web Application" template, and it works fine. So I guess there's one of the gazillion possible settings in my main project which isn't correct. But how can I figure out which one?

    I've attached my Web.Config and web project file,.


  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 08 Mar 2013 Link to this post

    Hello Andrew,

    We are not sure what exactly is the reason for this behavior and we need a project to run on our side to investigate further. Please remove all the depedencies which are not related to the problem and send us the project so we can search what exactly causes this behavior.

    Thank you in advance for the cooperation. 

    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Andrew
    Andrew avatar
    34 posts
    Member since:
    Dec 2010

    Posted 08 Apr 2013 Link to this post

    OK, I've managed to create a small project that replicates the crash.


    If you can tell me what I can do to stop this project crashing, I would be very grateful.
  5. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 10 Apr 2013 Link to this post

    Hello Andrew,

    Thank you for the sample project. After investigating the project we found out that you are missing part 3 from the getting started tutorial:

    http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/introduction#using-kendo-ui-in-asp.net-mvc-4-application

    Once you add these runtime bindings the project should start working properly.

    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Andrew
    Andrew avatar
    34 posts
    Member since:
    Dec 2010

    Posted 10 Apr 2013 Link to this post

    Thank you for the pointer. My sample project didn't have the bindings, but my real project already did have them, but still had the problem.

    Nevertheless, Your feedback lead me to do some more experimentation.

    In my Web.Config file I also had bindings for System.Web.Extensions and System.Web.Extensions.Design (as below). I assume these were left as some artifact of a previous framework version.

    I commented out these bindings, and now the Kendo MVC Tab control works.

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
       
          <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
          <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
          <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
        </dependentAssembly>
      </assemblyBinding>
    </runtime>
Back to Top
UI for ASP.NET MVC is VS 2017 Ready