直接根据dll实例化,不需要引用,但是需要已知命名空间和类名
using System.Reflection;
object instance;
......
private void Ini()
{
string str = System.IO.Directory.GetCurrentDirectory()+ "/det.dll";
Assembly asm = Assembly.LoadFile(str);
var type = asm.GetType("Test.Det"); //
instance = asm.CreateInstance("Test.Det");
var method = type.GetMethod("Ini");
//调用方法的一些标志位,这里的含义是Public并且是实例方法,这也是默认的值
BindingFlags flag = BindingFlags.Public | BindingFlags.Instance;
object[] parameters = new object[] { "", "./model/deploy.pkl", (uint)0};
object returnIng = method.Invoke(instance, flag, Type.DefaultBinder, parameters, null);
Console.WriteLine(returnIng); //Int类型
}
// 检测
private void Det(object sender, EventArgs e)
{
string str = System.IO.Directory.GetCurrentDirectory()+ "/det.dll";
Assembly asm = Ass