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

ArgumentNullException thrown in RouteCollection.SetItem

4 Answers 127 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Iron
Iron
Andrew asked on 06 Mar 2013, 11:47 PM
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,.


4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 08 Mar 2013, 12:35 PM
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!
0
Andrew
Top achievements
Rank 1
Iron
Iron
answered on 08 Apr 2013, 11:25 PM
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.
0
Petur Subev
Telerik team
answered on 10 Apr 2013, 08:37 AM
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!
0
Andrew
Top achievements
Rank 1
Iron
Iron
answered on 10 Apr 2013, 10:19 PM
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>
Tags
General Discussions
Asked by
Andrew
Top achievements
Rank 1
Iron
Iron
Answers by
Petur Subev
Telerik team
Andrew
Top achievements
Rank 1
Iron
Iron
Share this question
or