我在代码中动态加载了一个dll
Assembly.EmrAssembly=Assembly.LoadFrom(@"d:\test.dll");
Type typ = EmrAssembly.GetType("nameSp1.nameSp2.Class1");
object obj = Activator.CreateInstance(typ);
我要调用的方法ShowMsg()具有多个重载(如下):
ShowMsg(string msg);ShowMsg(string msg,int nID);ShowMsg(int nMsg,int nID);ShowMsg(string[] msgs);
请问我如果希望调用ShowMsg(int nMsg,int nID);这个重载应该怎样写?
Assembly.EmrAssembly=Assembly.LoadFrom(@"d:\test.dll");
Type typ = EmrAssembly.GetType("nameSp1.nameSp2.Class1");
object obj = Activator.CreateInstance(typ);
我要调用的方法ShowMsg()具有多个重载(如下):
ShowMsg(string msg);ShowMsg(string msg,int nID);ShowMsg(int nMsg,int nID);ShowMsg(string[] msgs);
请问我如果希望调用ShowMsg(int nMsg,int nID);这个重载应该怎样写?
{
private string returnString;
public string ReturnString
{
get { return returnString ; }
set { returnString = value ;}
}
public A()
{
}
public A(string str )
{
this.returnString = str;
}
public void FunctionWithoutParameter()
{
Console.WriteLine( "Without Parameter" );
}
public void FunctionWithParameter( string str )
{
Console.WriteLine( str );
}
}
object o = Activator.CreateInstance( type );
MethodInfo mi = type.GetMethod("FunctionWithoutParameter" );
mi.Invoke( o , null );object o = Activator.CreateInstance( type );
MethodInfo mi = type.GetMethod( "FunctionWithParameter" ,BindingFlags.Public|BindingFlags.Instance,null , new Type[]{ typeof(string) } , null );
mi.Invoke( o , new object[]{""} );
Type type,
params Object[] args//参数数组
)