【问题标题】:TypeLoadException in ASP.NET DevExtreme Datagrid when specifying columns指定列时 ASP.NET DevExtreme Datagrid 中的 TypeLoadException
【发布时间】:2020-09-08 08:33:50
【问题描述】:

我正在自定义 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);

我在这里错过了什么。

【问题讨论】:

    标签: asp.net-core devexpress devextreme


    【解决方案1】:

    TypeLoadException:无法从程序集“Microsoft.AspNetCore.Mvc.ViewFeatures, Version=3.1.7.0, Culture=neutral, PublicKeyToken=adb9793829ddae60”加载类型“Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ExpressionHelper”。

    在 ASP.NET Core 3.0 中,一些 pubinternal API(包括 Microsoft.AspNetCore.Mvc.ViewFeatures.Internal 命名空间)被更新为真正的内部 API,这似乎导致了这个问题。

    有关“在 MVC 内部制作“pubinternal”类型”的更多信息,请查看此链接:https://github.com/dotnet/aspnetcore/issues/4932

    作为一种可能的解决方法,您可以尝试使用 ASP.NET Core 2.x 而不是 ASP.NET Core 3+ 版本来设置项目。

    【讨论】:

    • 感谢您的帖子,但我只需要更新到最新版本的 DevExtreme。
    • 好的,问题似乎是您使用的是旧版本的 Devextreme,它将使用来自 Microsoft.AspNetCore.Mvc.ViewFeatures.InternalExpressionHelper。很高兴听到问题已解决:)。
    • 嗨@PlarentHaxhidauti,您可以将您的解决方案标记为答案,这将有助于其他社区快速找到此案例并解决类似问题。
    • 我会尽快,也就是两天后。再次感谢:-))
    【解决方案2】:

    问题已解决。默认情况下,当我在依赖项中安装 Devextreme 时,它​​不是最新版本。经过一番检查,我不得不更新 Devextreme 的版本,现在一切都很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-25
      • 1970-01-01
      相关资源
      最近更新 更多