只能在Type.IsGenericParameter为true的Type上调用获取方法。在我的ViewModel中的重载类型

时间:2012-04-16 17:20:30

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

这是基类中的属性

[ReadOnly(true), Display(GroupName = "Payment Details")]
public virtual GridViewModel<PaymentDetails> Details { get; set; } 

这是继承类中的属性

[Display(AutoGenerateField = false, AutoGenerateFilter = false), ScaffoldColumn(false)]
public override GridViewModel<PaymentDetails> Details { get; set; } 

我得到的方法只能在Type.IsGenericParameter为true的Type上调用。错误这是一个调用堆栈

[InvalidOperationException: Method may only be called on a Type for which Type.IsGenericParameter is true.]
   System.RuntimeType.get_DeclaringMethod() +9546416

[TargetInvocationException: Property accessor 'DeclaringMethod' on object 'System.RuntimeType' threw the following exception:'Method may only be called on a Type for which Type.IsGenericParameter is true.']
   System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component) +400
   System.Web.Mvc.<>c__DisplayClassb.<GetPropertyValueAccessor>b__a() +18
   System.Web.Mvc.ModelMetadata.get_Model() +19
   System.Web.Mvc.TemplateInfo.Visited(ModelMetadata metadata) +69

0 个答案:

没有答案