问题描述
我正在自定义DevExtreme中数据网格所需的列。以下是我的Index.cshtml和加载数据的操作方法。该模型具有更多属性,但我只想包括这三个属性。
@(Html.DevExtreme().DataGrid<ServicingRequestOrder.Models.GeneralInfo>
()
.ID("dataGrid")
.ShowBorders(true)
.DataSource(d => d.Mvc().Controller("GeneralInfo").LoadAction("IndexLoad").Key("ID"))
.Columns(columns =>
{
columns.AddFor(m => m.CustomerID);
columns.AddFor(m => m.Name);
columns.AddFor(m => m.Description);
}).
[HttpGet]
public object IndexLoad(DataSourceLoadOptions loadOptions)
{
var generalInfos = _context.GeneralInfos.ToList();
return DataSourceLoader.Load(generalInfos,loadOptions);
}
我得到的具体例外情况是
TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ExpressionHelper' from assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures,Version=3.1.7.0,Culture=neutral,PublicKeyToken=adb9793829ddae60'.
我也在Startup.cs中包含了此服务。
services.AddMvc().AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
我在这里想念什么。
解决方法
TypeLoadException:无法从程序集“ Microsoft.AspNetCore.Mvc.ViewFeatures,版本= 3.1.7.0,文化=中性,PublicKeyToken = adb9793829ddae60”中加载类型“ Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ExpressionHelper”。 >
在ASP.NET Core 3.0中,某些pubinternal API(包括Microsoft.AspNetCore.Mvc.ViewFeatures.Internal
名称空间)已更新为真正内部的,这似乎是导致此问题的原因。
有关“在MVC内部创建“ pubinternal”类型”的更多信息,请检查此链接:https://github.com/dotnet/aspnetcore/issues/4932。
作为一种可能的解决方法,您可以尝试使用ASP.NET Core 2.x而不是ASP.NET Core 3+版本来设置项目。
,问题已解决。默认情况下,当我在依赖中安装Devextreme时,它不是最新版本。经过一番检查之后,我不得不更新Devextreme的版本,现在一切都很好。