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

Kendo UI MVC 4 Exception

7 Answers 300 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 13 Aug 2012, 04:38 AM
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)


7 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 14 Aug 2012, 01:45 PM
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.
0
Jeff
Top achievements
Rank 1
answered on 15 Aug 2012, 01:50 PM
Hello? Is this an actively developed/supported product?
0
Daniel
Telerik team
answered on 15 Aug 2012, 05:08 PM
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!
0
Jeff
Top achievements
Rank 1
answered on 15 Aug 2012, 06:35 PM
   
<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.
0
Daniel
Telerik team
answered on 20 Aug 2012, 02:46 PM
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!
0
Buforad
Top achievements
Rank 1
answered on 21 Aug 2012, 04:44 AM
Great question Jeff. A big help here.

buy real google 1  |  buy google plus
0
Jeff
Top achievements
Rank 1
answered on 21 Aug 2012, 01:50 PM
Wow! D'oh! Thanks so much.
Tags
General Discussions
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Daniel
Telerik team
Buforad
Top achievements
Rank 1
Share this question
or