从配置文件读取这个方法所在的命名空间,类名,方法名。 执行方法,获取返回值。 //拼出dll所在的路径 string path = Assembly.GetExecutingAssembly().Location; path = path.Substring(0, path.LastIndexOf("//")) + "//Lib//"; path += ConfigManager.GetValue("BLLDisposalFileName"); //加载这个dll Assembly assembly = Assembly.LoadFrom(path); //命名空间 string classPath = ConfigManager.GetValue("BLLDisposalNameSpace"); Type type = (Type)assembly.GetType(classPath); if (type == null) { log.log("type创建错误"); } //获取类 object classObj = Activator.CreateInstance(type); //传参数 object[] objParams = { (object)resultMsgBody }; if (classObj == null) { log.log("类: " + null + "参数:" + objParams.ToString()); } else { log.log("类: " + classObj.ToString() + "参数:" + objParams.ToString()); } //执行类,返回返回值 object obj = type.InvokeMember("GetDisposalBLL", BindingFlags.Default | BindingFlags.InvokeMethod, null, classObj, objParams); if (obj == null) log.log("调用失败"); log.log("调用成功" + obj.ToString()); //获取返回值 resultMsgBody = obj.ToString();