string namespacestr="SKY.MODEL.UserModel";//命名空间
string methodname="GetValueByID";//方法名称
string str = namespacestr.Substring(0, namespacestr.LastIndexOf(".") );
//Type t = System.Type.GetType("SKY.MODEL.UserModel,SKY.MODEL");
try
{
Type t = System.Type.GetType(namespacestr + "," + str);
ConstructorInfo info = t.GetConstructor(new Type[] { });//根据该命名空间,实例化一个构造函数
Object o = info.Invoke(new object[] { });//根据构造函数,动态实例化一个对象
MethodInfo methods = t.GetMethod(methodname);//获取方法
Object obj = methods.Invoke(o, new Object[] { 1,propertyname, "", this.LANGUAGE });//执行该方法
}
catch (Exception e) {
Alert.Show("数据源命名空间:" + namespacestr + "不存在,或方法"+methodname+"不存在,请确认!");
return "";
}