Kendo UI MVC 4 Exception

8 posts, 0 answers
  1. Jeff
    Jeff avatar
    28 posts
    Member since:
    Aug 2010

    Posted 12 Aug 2012 Link to this post

    I'm evaluating Kendo UI for a new MVC application and I'm having trouble getting started. I followed all the set-up directions listed the in documentation here:

    http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/introduction

    but after putting the following on my home page

                 

         @Html.Kendo().AutoComplete()

            .Name("from")

            .DataTextField("Name")

            .DataSource(source =>

                        source.Read(read =>

                                    read.Action("Get", "Addresses")

            ).ServerFiltering(true))    

    I get:

    System.NullReferenceException occurred
      Message=Object reference not set to an instance of an object.
      Source=Kendo.Mvc
      StackTrace:
           at Kendo.Mvc.UI.WidgetExtensions.GetUnobtrusiveValidationAttributes(IWidget instance)
           at Kendo.Mvc.UI.Html.DropDownListHtmlBuilderBase.Build()
           at Kendo.Mvc.UI.AutoComplete.WriteHtml(HtmlTextWriter writer)
           at Kendo.Mvc.UI.WidgetBase.ToHtmlString()
           at Kendo.Mvc.UI.Fluent.WidgetBuilderBase`2.ToHtmlString()
           at System.Web.HttpUtility.HtmlEncode(Object value)
           at System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, Object content)
           at System.Web.WebPages.WebPageBase.Write(Object value)


  2. Jeff
    Jeff avatar
    28 posts
    Member since:
    Aug 2010

    Posted 14 Aug 2012 Link to this post

    Hello?

    I turned off "Just my Code" and can see that the issue is that "name" is null on the Widget, despite the fact that I'm calling

    .Name("from")
     

    in the code.
  3. Jeff
    Jeff avatar
    28 posts
    Member since:
    Aug 2010

    Posted 15 Aug 2012 Link to this post

    Hello? Is this an actively developed/supported product?
  4. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 15 Aug 2012 Link to this post

    Hello Jeff,

    The most likely reason for the exception is that the runtime assembly binding configuration for older versions of MVC is missing in the Web.config which at least for is needed. Please check if adding the following configuration resolves the problem.

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
          <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
        </dependentAssembly>
      </assemblyBinding>
    </runtime>

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Jeff
    Jeff avatar
    28 posts
    Member since:
    Aug 2010

    Posted 15 Aug 2012 Link to this post

       
    <dependentAssembly>
         <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
         <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
       </dependentAssembly>

    is already in my top level web.config (it was added by default when I created the new project).

    I changed 0.0.0.0 to 1.0.0.0, but that had no effect (nor would I expect it to).

    My whole assemblyBinding section looks like
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
           <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
           <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
           <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
           <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="Raven.Client.Lightweight" publicKeyToken="37f41c7f99471593" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="Raven.Abstractions" publicKeyToken="37f41c7f99471593" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
         </dependentAssembly>
       </assemblyBinding>


    My page looks like 

    @model ViewModels.AddressViewModel

    @Html.Kendo().AutoComplete()
    .Name("fromAddress").DataTextField("Name") .DataSource(source => source.Read(read=>
    read.Action("Get", "Addresses") ).ServerFiltering(true))

    This cshtml is rendered by my Index.cshtml via a call to 
    @Html.Partial("Addresses", new AddressViewModel())

    ...but I've tried putting the AutoComplete on other pages altogether (without any ViewModels or Partial views and get the same result.

    hopefully that adds some more context.
  6. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 20 Aug 2012 Link to this post

    Hello again Jeff,

    Sorry, I missed that the AutoComplete definition is not correct. Since you are declaring the control on multiple rows, you should use it inside an explicit code nugget instead of an implicit one. For example:

     @(Html.Kendo().AutoComplete()
            .Name("from")
            .DataTextField("Name")
            .DataSource(source =>
                        source.Read(read =>
                                    read.Action("Get", "Addresses")
            ).ServerFiltering(true))
     )

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Buforad
    Buforad avatar
    1 posts
    Member since:
    Aug 2012

    Posted 20 Aug 2012 Link to this post

    Great question Jeff. A big help here.

    buy real google 1  |  buy google plus
  8. Jeff
    Jeff avatar
    28 posts
    Member since:
    Aug 2010

    Posted 21 Aug 2012 Link to this post

    Wow! D'oh! Thanks so much.
Back to Top