Assembly amb = Assembly.LoadFrom(@"F:\Job\组件商城20111118\商城代码2011-11-18\Source Code\MSBLL\bin\Debug\MSBLL.dll");
Type tt = amb.GetType("MSBLL.IndentManage");
object obj = amb.CreateInstance("MSBLL.IndentManage");
MethodInfo[] methodInfo = tt.GetMethods();
MethodInfo info = tt.GetMethod("DownUrl");MSBLL程序集中的类IndentManage的方法DownUrl如下:
public string DownUrl(string id)
{
string sqlstr = "select file_path from MS_Files where moduleid=" + id;
return DbHelperSQL.ExSqlReturn(sqlstr);
}我怎么用反射机制的Invoke来调用这个方法??
请高手指点,不胜感激!!
Type tt = amb.GetType("MSBLL.IndentManage");
object obj = amb.CreateInstance("MSBLL.IndentManage");
MethodInfo[] methodInfo = tt.GetMethods();
MethodInfo info = tt.GetMethod("DownUrl");MSBLL程序集中的类IndentManage的方法DownUrl如下:
public string DownUrl(string id)
{
string sqlstr = "select file_path from MS_Files where moduleid=" + id;
return DbHelperSQL.ExSqlReturn(sqlstr);
}我怎么用反射机制的Invoke来调用这个方法??
请高手指点,不胜感激!!
public static string ExSqlReturn(string Sqlstring)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand(Sqlstring, connection))
{
try
{
connection.Open();
if (cmd.ExecuteScalar() == null)
return "";
else
return cmd.ExecuteScalar().ToString();
}
catch (System.Data.SqlClient.SqlException e)
{
connection.Close();
throw e;
}
}
}
}
Type tt = amb.GetType("MSDAL.DbHelperSQL");
MethodInfo info = tt.GetMethod("ExSqlReturn");
info.Invoke(null,new object[]{"1"})
Type tt = amb.GetType("MSBLL.IndentManage");
object obj = amb.CreateInstance("MSBLL.IndentManage");
MethodInfo[] methodInfo = tt.GetMethods();
MethodInfo info = tt.GetMethod("DownUrl");MSBLL程序集中的类IndentManage的方法DownUrl如下:
public string DownUrl(string id)
{
string sqlstr = "select file_path from MS_Files where moduleid=" + id;
return DbHelperSQL.ExSqlReturn(sqlstr);
}我怎么用反射机制的Invoke来调用这个方法??
DownUrl方法里面又有一个位于MSDAL命名空间下的DbHelperSQL类的方法:
ExSqlReturn(string Sqlstring)
用反射共涉及到二个方法了,这怎么用啊,
具体问题,再特殊对待;