简体   繁体   English

无法对ContainsGenericParameters为true的类型或方法执行后期绑定操作

[英]Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true

I've got an extension for all entities: 我有一个所有实体的扩展:

 public static class EntityBaseExtensions
    {
        public static T Clone<T>(this T item)
            where T : EntityBase
        {
            return item.EntityClone<T>();
        }
    }

and

 public virtual T EntityClone<T>() where T : EntityBase
        {
            return this.MemberwiseClone() as T;
        }

but when i call it like: 但当我称之为:

 var details = user.Details.Clone();

i get 我明白了

Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true. 无法对ContainsGenericParameters为true的类型或方法执行后期绑定操作。

any ideas? 有任何想法吗?

the solution is kinda weird: 解决方案有点奇怪:

public static T Clone<T>(this T item)
    where T : SimpleEntityBase
{
    return (T)item.EntityClone();
}

and

public virtual object EntityClone()
{
    return this.MemberwiseClone();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#无法创建实例,因为Type.ContainsGenericParameters为true - C# Cannot create an instance because Type.ContainsGenericParameters is true 无法创建实例,因为Type.ContainsGenericParameters为true - Cannot create an instance of because Type.ContainsGenericParameters is true 无法创建 Android.Widget.ArrayAdapter`1[T] 的实例,因为 Type.ContainsGenericParameters 为 true - Cannot create an instance of Android.Widget.ArrayAdapter`1[T] because Type.ContainsGenericParameters is true 无法创建FluentNHibernate.Automapping.AutoMapping Namespace.Class [T]的实例,因为Type.ContainsGenericParameters为true - Cannot create an instance of FluentNHibernate.Automapping.AutoMapping Namespace.Class[T] because Type.ContainsGenericParameters is true 如何从后期绑定的COM对象获取方法列表 - How to get a list of Methods from a late bound COM object 如果 Type.IsGenericParameter == true,Type.ContainsGenericParameters == true 是否总是? - If Type.IsGenericParameter == true, will Type.ContainsGenericParameters == true always? 从fieldinfo获取泛型值会引发异常:“无法执行后期边界操作...” - Getting generic value from fieldinfo throws exception: “Late bounds operation cannot be performed…” 如何在没有IDL或后期绑定调用远程处理方法的情况下访问CORBA接口 - How to access CORBA interface without IDL or late-bound invoke remoting methods 温莎城堡的“后期绑定”组件 - Castle Windsor “Late bound” components 无法绑定到WPF / RadComboBox中绑定到数据的数据 - Cannot tyoe in WPF/RadComboBox which is bound to data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM