您的位置:首页 > 其它

哪位高手知道这是怎么回事?怎么解决?急!!!

2008-02-25 09:39 295 查看
请位各位下面的问题怎么解决?

Form parentFrm = this.Owner;
getValue g = new getValue(MakeItem.GetValueControlProperty);
RuleEName = g(parentFrm,"TbEnglishName","Text").ToString();//调用,TbEnglishName是textbox的名称

public static object GetValueControlProperty(object ClassInstance,string ControlName,string PropertyName)
{
object Result=null;
Type myType = ClassInstance.GetType();
FieldInfo myFieldInfo = myType.GetField( ControlName,
BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.Public | BindingFlags.Instance);

//FieldInfo myFieldInfo = myType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

if(myFieldInfo != null)
{
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(myType);
PropertyDescriptor myProperty = properties.Find(PropertyName, false);

if(myProperty != null)
{
object ctr;

ctr = myFieldInfo.GetValue(ClassInstance);

try
{
Result = myProperty.GetValue(ctr);//这个地方出错,有异常发生,信息如下图.
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"Error");
}
}
}
return Result;
}

异常捕捉结果:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐