1.调用静态类public静态普通方法 ExecuteDataTable
var business = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(dll => dll.ManifestModule.ScopeName.ToLower() == "firstelite.oms.business.dll"); var sql = @"SELECT * FROM Table WHERE username=@LoginID)"; var dt = business.GetType("Firstelite.OMS.Business.Data.OMSSqlClientManager").InvokeMember("ExecuteDataTable" , System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public , null, null, new object[] { sql, new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@LoginID", loginID) } }) as System.Data.DataTable;
2.调用静态类泛型类型为string的public静态方法 Convert
var pass = business.GetType("FirsteLite.OMS.Business.Helper.ConvertHelper").GetMethod("Convert" , System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).MakeGenericMethod(typeof(string)).Invoke(null, new object[] { dt.Rows[0]["password"], string.Empty });