Search code examples
c#asp.net-mvcasp.net-corekendo-ui.net-9.0

Can we use Kendo UI in .NET 9?


I have migrated my .NET 4.8 project to .NET 9 using Upgrade Assistant. After removing errors and making its build I tried to run the project. I added Kendo as a service in my Program.cs file. When I try to run the project I am getting this error.

I have installed KendoUI_2023from package manager console.

System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Kendo.Mvc.Rendering.IKendoHtmlGenerator Lifetime: Transient ImplementationType: Kendo.Mvc.Rendering.KendoHtmlGenerator': Could not load type 'Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.)'

is Kendo UI depreciated in .NET 9 ?


Solution

  • First, according to the Telerik UI roadmap, we can see the Telerik UI support .NET 9. And I also test the Kendo UI for jQuery in my .NET 9 MVC application, everything works well.

    In my sample, I'm using the following reference in the layout page:

    @* <script src="~/lib/jquery/dist/jquery.min.js"></script> *@
    
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2024.4.1112/js/kendo.all.min.js"></script>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/themes/10.0.1/default/default-ocean-blue.css">
    <script src="https://unpkg.com/jszip/dist/jszip.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    @await RenderSectionAsync("Scripts", required: false)
    

    So you can refer to the Telerik UI tutorial and Kendo UI for jQuery to use them in your application.

    System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Kendo.Mvc.Rendering.IKendoHtmlGenerator Lifetime: Transient ImplementationType: Kendo.Mvc.Rendering.KendoHtmlGenerator': Could not load type 'Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.)'

    Second, about this issue, the Microsoft.AspNetCore.Mvc.Core package is marked as deprecated. You could check the document related

    With the release of .NET Core 3.0, many ASP.NET Core assemblies are no longer published to NuGet as packages. Instead, the assemblies are included in the Microsoft.AspNetCore.App shared framework, which is installed with the .NET Core SDK and runtime installers. For a list of packages no longer being published, see Remove obsolete package references.

    So, in the .NET 9 application, you can uninstall the Microsoft.AspNetCore.Mvc.Core package. We just need to set the sdk as below:

    <Project Sdk="Microsoft.NET.Sdk.Web">
       ......
    </Project>
    

    More detail information, see Microsoft.AspNetCore.App for ASP.NET Core.