可以这样写呀,只要test.module类继承了IMoudle接口就可以
下面是我写的测试例子并通过了测试//类和接口定义
namespace test
{
/// <summary>
/// Moudle 的摘要说明。
/// </summary>
public class Moudle:IMoudle
{
public Moudle()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region IMoudle 成员 public int Add(int i, int j)
{
// TODO:  添加 Moudle.Add 实现
return (i+j);
} #endregion
} public interface IMoudle
{
int Add(int i,int j);
}
}
//反射测试
private void button1_Click(object sender, System.EventArgs e)
{
 System.Reflection.Assembly a=System.Reflection.Assembly.GetAssembly(typeof(test.Moudle));
 object o=a.CreateInstance("test.Moudle");
 test.IMoudle m=(test.IMoudle)o;
 int i=m.Add(100,123);
}

解决方案 »

  1.   

    估计你d:\\test.dll动态库里的test类没有继承IMoudle接口,或者是继承的接口定义和你调用的IMoudle接口定义不是同一个接口定义(必须是同一接口定义,即使是两个定义一样的接口也不行)
      

  2.   

    我的动态库里的module类实现了IModule接口阿,这两个工程中的接口文件是一模一样的
      

  3.   

    光是名称一样是不行的。.Net是通过将检查程序集信息。
    需要将IMoulde定义在一个公共的程序集中。
      

  4.   

    <param name="DllName">动态连接库名</param>
    <param name="ClassFullName">类全名(包括命名方法)</param>
    <param name="MethodName">方法名</param>
    <param name="ClassConstructParam">类构造函数参数数组</param>
    <param name="MethodParam">方法数组</param>
    <param name="Result">返回的结果</param>
    <param name="ErrorMessage">错误信息</param>
    Assembly a=Assembly.Load(DllName);
    Type mytypes = a.GetType(ClassFullName);
    MethodInfo mi = mytypes.GetMethod(MethodName);
    Object obj = a.CreateInstance (ClassFullName,true, System.Reflection.BindingFlags.CreateInstance,null, ClassConstructParam,null,null);

    Result=mi.Invoke(obj,MethodParam).ToString();