- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试获取 MethodInfo
来自方法 TableExists<T>
所以我可以用一个类型来调用它。
该方法在 OrmLiteSchemaApi
中声明类(class)。有2个重载:
public static bool TableExists<T>(this IDbConnection dbConn)
{
// code omitted
}
public static bool TableExists(this IDbConnection dbConn, string tableName, string schema = null)
{
// code omitted
}
MethodInfo
像这样:
var tableMethod = typeof(OrmLiteSchemaApi).GetMethod("TableExists");
System.Reflection.AmbiguousMatchException: 'Ambiguous match found.'
MethodInfo
?
最佳答案
您可以使用 GetMethods
(复数!)获取所有匹配方法的数组,然后查找具有 IsGenericMethod
的方法。 :
var tm = typeof(OrmLiteSchemaApi)
.GetMethods()
.Where(x => x.Name == "TableExists")
.FirstOrDefault(x => x.IsGenericMethod);
关于c# - System.Reflection.AmbiguousMatchException : 'Ambiguous match found.' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56083067/
我写了这段代码: MethodInfo method2 = typeof(IntPtr).GetMethod( "op_Explicit", Bind
using System; using System.Reflection; namespace A { interface IObjectWithId { TId Id { get;
我得到异常(exception): AmbiguousMatchException: ambiguous match found 当打开我的窗口时,XAML被解析。我有一个基本的ViewModel类。
我有以下(简化的)类(class): public abstract class BaseSite { public int SiteId { get; set; } public s
我正在尝试在我的代码重载签名中测试(使用 Moq)重载 protected 泛型方法: protected void AutoMap(IList sources
我正在寻找一种解决方案来访问类的“展平”(最低)属性值及其通过属性名称的反射派生的值。 即从 ClassB 或 ClassC 类型访问 Property1 或 Property2 : publi
我有两个名称相同但方法签名不同的 Controller 操作。它们看起来像这样: // // GET: /Stationery/5?asHtml=true [AcceptVer
我正在使用反射创建一个 lambda 函数。它适用于我尝试过的大多数项目,但是在其中一个属性上它一直抛出不明确的匹配异常。 代码如下所示。当它命中 Expression.PropertyOrField
我有两个名称相同但大小写不同的属性 Title 和 TITLE: public class Product { [Key] public Guid Id { get; set; }
昨天我在开发 Web 部件时遇到了一个问题(这个问题不是关于 webpart 而是关于 C#)。关于这个问题的背景很少。我有一个使用反射加载 WebPart 的代码,其中我得到了 AmbiguousM
当我使用 JSON.NET 在 LINQPad 中运行此代码时: var x = JObject.Parse( @"{ ""data"" : [ { ""id"" : ""bbab529e
我正在尝试获取 MethodInfo来自方法 TableExists所以我可以用一个类型来调用它。 该方法在 OrmLiteSchemaApi 中声明类(class)。有2个重载: public st
我正在开发一个有点简单的 InventoryTracker MVC5 应用程序,其中我在将 LocalDatabase 设置为 Seed() 时遇到了一些问题. 当我运行 update-databas
我是一名优秀的程序员,十分优秀!