c# - 安装了两个网格包: The call is ambiguous between the following methods or properties

标签 c# asp.net-mvc asp.net-mvc-4

我继承了一个相当旧的 MVC 项目,它安装了 Grid 包,Grid.MVC。它被广泛使用,并且不能将其取出或更换(客户不会为此付费。)

我们刚刚为网站构建了一个新的门户部分,在其中我们使用了一个新的(更好的)网格,NonFactors.Grid.Core.MVC5。更多功能和选项。

但是问题来了。在所有使用旧网格的地方,我现在都会收到此运行时错误:

The call is ambiguous between the following methods or properties: 'NonFactors.Mvc.Grid.MvcGridExtensions.Grid(System.Web.Mvc.HtmlHelper, System.Collections.Generic.IEnumerable)' and 'GridMvc.Html.GridExtensions.Grid(System.Web.Mvc.HtmlHelper, System.Collections.Generic.IEnumerable)'

这应该是一个简单的修复。我需要做的就是告诉旧网格它们是哪一个。但我不明白语法。在 View 中,它们都有一个 @using 指向正确的(旧)版本。

@using GridMvc.Html
....
@Html.Grid(Model.Leads).Named("userGrid").Selectable(false).Columns(c =>
{
     ....
}

图片可能更有帮助:

enter image description here

我尝试了 View 中完整路径的各种方法,但语法从来都不正确......

@GridMvc.Html.GridExtensions.Grid(Model.Leads)....  // Nope
@Html.GridMvc.Html.GridExtensions.Grid(Model.Leads)....  // Nope

等等等等

同样,这可能很简单。我只是不明白。

最佳答案

尝试将 HtmlHelper 实例作为第一个参数传递给扩展方法:

@NonFactors.Mvc.Grid.MvcGridExtensions.Grid(Html, Model.Leads)
@GridMvc.Html.GridExtensions.Grid(Html, Model.Leads)

关于c# - 安装了两个网格包: The call is ambiguous between the following methods or properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41634271/

相关文章:

javascript - 电话号码验证正则表达式由一个加号开始和前面的数字组成

c# - 在什么情况下我会将操作指定为未选中?

c# - .NET Core Web Deploy to production 在发布时关闭站点?

c# - Delphi 扩展到 C#

c# - 在 VS 2017、MVC 中添加服务引用

ASP.NET Mvc 5 返回带有 seo 友好 url 的 View

c# - Paypal Ipn 与 asp.net MVC 集成

javascript - knockout MVC,绑定(bind)模型并将对象添加到模型

c# - 不同分辨率下的 Windows 窗体大小问题

c# - 如果结构包含 DateTime 字段,为什么 LayoutKind.Sequential 的工作方式不同?