///m中的方法调用
private object invo()
{
MWArray filename = @"E:\\l.DAT" ; //M文件中的方法参数
Assembly MyAssembly = Assembly .LoadFrom("testExample.dll"); //使用Assembly动态调用Matlab生成的dll
Type[] types = MyAssembly.GetTypes(); //得到方法集合
foreach (Type t in types)
{
if (t.Namespace == "testExample" && t.Name == "CTestExample")
{
MethodInfo m = t.GetMethod("func_test_main" , new Type[] { typeof(MWArray ) }); //根据方法名称和方法中的参数去查找具体需要的方法
if (m != null )
{
object o = Activator .CreateInstance(t); //生成对象实例
return m.Invoke(o, new object[] { filename });//调用方法
}
}
}
return (object )0;
}
原文地址:http://blog.csdn.net/wwwdongzi/article/details/42099103