telerik / kendo-ui-core

An HTML5, jQuery-based widget library for building modern web apps.
http://www.telerik.com/kendo-ui
Other
2.53k stars 1.91k forks source link

Kendo.Mvc 2016.2.617 throws TypeLoadException in Asp.Net Core 1.0 RTM #1856

Closed PSCAlex closed 8 years ago

PSCAlex commented 8 years ago

Kendo.Mvc 2016.2.617 is throwing a TypeLoadException when using services.AddKendo() in startup.cs. This error has only started since upgrading from RC2 to RTM.

The error is

System.TypeLoadException
Could not load type 'Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions' 
from assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, 
Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.AddKendo(IServiceCollection services)
Eneuman commented 8 years ago

Got the same problem here.

mjhixson commented 8 years ago

Same issue, possibly tied to this breaking change?

Vasim-DigitalNexus commented 8 years ago

Same here, also suspect it's due to RTM breaking changes

deonvs commented 8 years ago

Same issue here. Any time frame when an update or fix would be available?

Tiger333 commented 8 years ago

Yep Same Issue

mjhixson commented 8 years ago

There is a Kendo.Mvc 2016.2.630 internal build available that seems to fix this issue. Wasn't able to find it on their nuget site, but if you log in to your telerik account and go to your product downloads, it should be listed there under internal builds.

cbettero commented 8 years ago

Ok Tomorrow we will try the build !

vdachev commented 8 years ago

Unfortunately, the 2016.2.630 internal build downloads are missing a .nupkg file.. :(

mjhixson commented 8 years ago

The nupkg is in \wrappers\aspnetmvc\Binaries\Mvc6

deonvs commented 8 years ago

It seems like this is not working with the Kendo Grid. Or at least not with returning Json from a Read action in the grid.

@(Html.Kendo().Grid<EmployeeModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.EmployeeID).Visible(false);
        columns.Bound(p => p.Name);
        columns.Bound(p => p.Salary);
    })
    .Pageable()
    .HtmlAttributes(new { style = "height:550px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Action("Employees_Read", "Home"))
     )
     .Deferred()
)

This is the Read Action in the controller:

public ActionResult Employees_Read([DataSourceRequest] DataSourceRequest request)
        {
            List<EmployeeModel> employees = new List<EmployeeModel>();
            employees.Add(new EmployeeModel() { EmployeeID = 1, Name = "Peter Pan", Salary = new decimal(23340.35) });
            employees.Add(new EmployeeModel() { EmployeeID = 2, Name = "Little John", Salary = new decimal(25320.45)});
            employees.Add(new EmployeeModel() { EmployeeID = 3, Name = "Tinkerbell", Salary = new decimal(21520.45) });
            employees.Add(new EmployeeModel() { EmployeeID = 4, Name = "Captain Hook", Salary = new decimal(45320.45) });
            var checkResult = employees.ToDataSourceResult(request);
            return Json(checkResult);
        }

With a simple Model:

public class EmployeeModel
    {
        public int EmployeeID { get; set; }
        public string Name { get; set; }
        public decimal Salary { get; set; }
    }

Below is a test solution to illustrate this. TestKendoGridWithCore1_0RTM.zip

vdachev commented 8 years ago

I can confirm that the ASP.NET Core 1.0 Final project now runs with Keno.Mvc 2016.2.630. I'll be going through the functionality of the components today.

vdachev commented 8 years ago

@deonvs , I experience the same issues and it's not just the Grid, but also DropDownList (and I suppose any other component). The browser console dumps an error:

Uncaught TypeError: Cannot read property 'slice' of undefined in "kendo.all.js", the undefined thing being the data from the JSON response.

Eneuman commented 8 years ago

This is probably because MS Changes Json serialization in the RTM bits to always be pascalCase. You can probably mitigate this by adding a json option like this:

change

services.AddMvc(); to

services
        .AddMvc()
        .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

until Telerik updates all the JavaScripts

cbettero commented 8 years ago

I only find the 617 version; where is the 630 ?

vdachev commented 8 years ago

@Eneuman , indeed that seems to be the case and the code snippet solves the issue. Thanks!

deonvs commented 8 years ago

@cbettero You have to log into Telerik site under your profile and go to download. Then select internal builds. This is not an official release yet.

deonvs commented 8 years ago

@Eneuman That seems to work. Thank you for the input.

Jekata commented 8 years ago

I can confirm that the solution provided by @Eneuman is fine.

Eneuman commented 8 years ago

@Jekata You realy need to push this to nuget if you want us to test it.

The normal way is to push it as a preview to nuget. That way VS will not find it until you you mark the "include previews" checkbox, but build servers and everything else will work and we can give you good solid feedback on the package.

You also should redact 2016.2.616 from nuget since this was a faulty build.

Nuget previews = internal builds.

Jekata commented 8 years ago

Hi folks,

The requested preview NuGet package is live at https://www.nuget.org/packages/Kendo.Mvc/2016.2.630-Preview.

Feel free to download and test it. As soon as we get enough feedback, we will be able to incorporate it in the official version.

Vasim-DigitalNexus commented 8 years ago

@Jekata, looks like 2016.2.630 still requires the .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); as @Eneuman mentioned

Jekata commented 8 years ago

@Vasimovic and @Eneuman

The code below

.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver())

is a project setting and it will be one of the configuration steps required to configure and run the Telerik UI for ASP.NET MVC components under ASP.NET Core (MVC6).

This step will be added to the Get Started article http://docs.telerik.com/kendo-ui/aspnet-mvc/mvc-6/getting-started.

vdachev commented 8 years ago

@Jekata , wouldn't it be better if Kendo UI MVC wrappers read these settings and comply with them? Imagine an existing project w/ loads of Javascript that relies on the serialization contract. It would require a significant effort to refactor these Javascripts, if the serialization contract is changed, just to start using the Kendo UI MVC wrappers.

tsvetomir commented 8 years ago

Detecting the serialization settings automatically is not possible, as these can be set locally:

public IActionResult Read()
{
  // Override serializer settings per-action
  return Json(
     MyModel,
     new JsonSerializerSettings { ContractResolver = new DefaultContractResolver() }
  );
}

Luckily this same feature also allows us to integrate into an existing project without disrupting it. I assume this is the major concern of @vdachev and it's pretty easy to work around. This is something that we'll add to the documentation as well /cc @ivanchev

If we decide to implement it, we'd have to explicitly declare an option on the component that declares what type of serialization to expect. Then we'll have to monkey-patch all expressions, model metadata and so on to expect this change.

Finally, we always have the option of making the model fields camelCase to start with. But that would look too much like Java :)

cbettero commented 8 years ago

Hi,

I agree with your point of view; It's a feature, not a problem.

Thanks!

 Corrado Bettero
 CIDITECH s.r.l.