动态加载dll

string   DllPath   =   Application.StartupPath   +   @ "\someDLL.dll "; 
System.Reflection.Assembly   assmble   =   System.Reflection.Assembly.LoadFile(DllPath); 
Type   tmpType   =   assmble.GetType( "someDLL.ClassA "); 
System.Reflection.MethodInfo   tmpM   =   tmpType.GetMethod( "Add "); 
object   tmpobj   =   assmble.CreateInstance( "someDLL.ClassA "); 
int   i   =   (int)tmpM.Invoke(tmpobj,   new   object[]{2,3}); 
----------ClassA的定义-------------------- 
using   System; 
namespace   someDLL 
///   <summary> 
///   ClassA   的摘要说明。 
///   </summary> 
public   class   ClassA 
public   ClassA() 
// 
//   TODO:   在此处添加构造函数逻辑 
// 
public   int   Add(int   a,   int   b) 
return   a+b; 
原文地址:https://www.cnblogs.com/top5/p/1988852.html