We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

.NET 7 TypeLoadException

I'm trying to use components in an ASP.NET Core project with .NET 7.

@Html.EJS().TextBoxFor(m => m.Email).Placeholder("Email").FloatLabelType(FloatLabelType.Auto).Render()

If I use @Html.EJS().TextBox("AAA").Placeholder("Email").FloatLabelType(FloatLabelType.Auto).Render() it works fine my If I use TextBoxFor (already used in MVC Standard) and I get this error:

An unhandled exception occurred while processing the request.

TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ExpressionHelper' from assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Syncfusion.EJ2.TextBoxForExtension.TextBoxFor<TModel, TProperty>(EJ2For<TModel> factory, Expression<Func<TModel, TProperty>> expression, TextBox model, object objHtmlAttr, Dictionary<string, object> htmlAttributes)


  • Syncfusion.EJ2.TextBoxForExtension.TextBoxFor<TModel, TProperty>(EJ2For<TModel> factory, Expression<Func<TModel, TProperty>> expression, TextBox model, object objHtmlAttr, Dictionary<string, object> htmlAttributes)

  • Syncfusion.EJ2.TextBoxForExtension.TextBoxFor<TModel, TProperty>(EJ2For<TModel> factory, Expression<Func<TModel, TProperty>> expression)

  • AspNetCoreGeneratedDocument.Views_Account_LoginGestore.ExecuteAsync() in LoginGestore.cshtml

    1. @Html.EJS().TextBoxFor(m => m.Email).Placeholder("Email").FloatLabelType(FloatLabelType.Auto).Render()
  • Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)

  • Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)

  • Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, string contentType, Nullable<int> statusCode)

  • Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)

  • Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

  • Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

  • Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

  • Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

  • Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)

  • Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)

  • Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)


5 Replies

UD UdhayaKumar Duraisamy Syncfusion Team January 5, 2023 03:29 PM UTC

Based on the shared information we suspect that you are trying to use the Syncfusion Textbox component in your ASP.Net core project. To use the Syncfusion TextBox component in ASP.Net core, you can follow the documentation provided in the following link.

https://ej2.syncfusion.com/aspnetcore/documentation/textbox/getting-started#add-aspnet-core-textbox-control


Online Demo (TextboxFor) : https://ej2.syncfusion.com/aspnetcore/TextBoxes/TextboxFor#/bootstrap5


If you are still encountering issues with the TextBoxFor method, please provide a runnable sample that replicates the issue so that we can test and troubleshoot the issue more efficiently.



MA Marco January 5, 2023 04:07 PM UTC

If I use tag helpers it works but if I use HTML Helper I have the error.

@Html.EJS().TextBoxFor(m => m.Email).Placeholder("Email").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Auto).Render()

TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ExpressionHelper' from assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.


Is it possible to use HTML Helper with viewmodel?



BH BharatRam Harikrishnan Syncfusion Team January 20, 2023 05:54 AM UTC

Hi Marco,


We can replicate the issue and logged bug report.

https://www.syncfusion.com/feedback/40523/-net-7-typeloadexception


The fix will be available in weekly release on February 1st week. In meantime, you can use components using tag helpers.

https://ej2.syncfusion.com/aspnetcore/documentation/getting-started/aspnet-core-mvc-taghelper


Regards,

Bharat Ram H



BH BharatRam Harikrishnan Syncfusion Team February 9, 2023 05:58 AM UTC

Hi Marco,

 

We could not include the fix for the reported issue in this weekly release (v20.4.0.49) due to some unavoidable circumstances. However, we have prepared a custom package with a solution in the same version. Please check that from below and let us know.

 

https://www.syncfusion.com/downloads/support/directtrac/general/ze/customPatch-v20.4.0.49-290803720

 

It will be included in our next weekly release which is scheduled for February 14th, 2023.

 

Regards,

Bharat Ram H



BH BharatRam Harikrishnan Syncfusion Team February 14, 2023 03:17 PM UTC

Hi Marco,

 

The fix for the reported issue is included in this weekly release (v20.4.0.50). Please check the link below and let us know if you have any further issues.

https://www.nuget.org/packages/Syncfusion.EJ2.AspNet.Core/20.4.0.50

 

Regards,

Bharat Ram H


Loader.
Live Chat Icon For mobile
Up arrow icon