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)
Got the same problem here.
Same issue, possibly tied to this breaking change?
Same here, also suspect it's due to RTM breaking changes
Same issue here. Any time frame when an update or fix would be available?
Yep Same Issue
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.
Ok
Tomorrow we will try the build !
Unfortunately, the 2016.2.630 internal build downloads are missing a .nupkg file.. :(
The nupkg is in \wrappersaspnetmvc\Binaries\Mvc6
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
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.
@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", theundefinedthing being thedatafrom the JSON response.
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
.AddMvc()
.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
until Telerik updates all the JavaScripts
I only find the 617 version; where is the 630 ?
@Eneuman , indeed that seems to be the case and the code snippet solves the issue. Thanks!
@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.
@Eneuman That seems to work. Thank you for the input.
I can confirm that the solution provided by @Eneuman is fine.
@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.
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.
@Jekata, looks like 2016.2.630 still requires the .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); as @Eneuman mentioned
@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.
@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.
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 :)
Hi,
I agree with your point of view;
It's a feature, not a problem.
Thanks!
Corrado Bettero
CIDITECH s.r.l.
Most helpful comment
@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.