【发布时间】:2011-02-19 00:57:54
【问题描述】:
我有一个 propertyInfo 对象,我尝试使用它执行 GetValue。
object source = mysourceObject //This object has a property "Prop1" of type Collection<>.
var propInfo = source.GetType().GetProperty("Prop1");
var propValue = prop.GetValue(this, null);
// do whatever with propValue
// ...
GetValue() 调用出错,因为“值不能为空。\r\n参数名称:源”
“Prop1”是一个声明为 Collection 的普通属性。
prop.PropertyType = {Name = "Collection1" FullName = "System.Collections.ObjectModel.Collection1[[Application1.DummyClass, Application1, Version=1.5.5.5834, Culture=neutral, PublicKeyToken=628b2ce865838339]]"} System.Type {System.RuntimeType}
【问题讨论】:
标签: .net exception reflection