//获取类反射对象
Type types = Assembly.Load("App_Code").CreateInstance("AnalyFunctions").GetType();
object[] objec2 = { (object)valuess };
string fac="method1";
//获取方法的返回值
values2 = (string)types.GetMethod(fac).Invoke(null, objec2);若method1方法存在重载,则报参数不匹配错误,如果能解决这个问题!
//查找一个参数是int和string的method1方法
Type[] paramTypes = {typeof(int),typeof(string)};
string fac="method1";
GetType().GetMethod(fac, paramTypes).Invoke(...);
values2 = (string)types.GetMethod(fac).Invoke(null, objec2);
//改为 //获取方法的返回值
values2 = (string)types.GetMethod(fac).Invoke(objec2, null);
private MethodInfo GetMethodInfo(Type type, string methodName, int paramCount)
{
return type.GetMethods().FirstOrDefault(m => { return m.Name == methodName && m.GetParameters().Count() == paramCount; });
} MethodInfo method = GetMethodInfo(this.GetType(), "ABC", 0);
if (method != null)
{
//todo
}