我在页面写这样的代码
System.Reflection.Assembly MyM= System.Reflection.Assembly.Load("MyModel");
其中MyModel是程序集名称
为什么我需要在页面层添加MyModel层的引用才可以正常运行
而页面层没有MyModel层引用的话就报下面错误
Could not load file or assembly 'MyModel' or one of its dependencies. The system cannot find the file specified.
难道用反射一定要先引用才能用?

解决方案 »

  1.   

    反射,反射没有了引用,也就没有物理DLL,没有了DLL,哪里获取类的信息?
      

  2.   

                 
    System.Reflection.Assembly.LoadFile("dll文件路径").CreateInstance("要反射的命名空间+类");
      

  3.   

    System.Reflection.Assembly MyM= System.Reflection.Assembly.Load("MyModel"); 也就是说Load方法使用范围是本程序集,而不是整个决绝方案?加载的是本程序集引用的dll?
      

  4.   

    没人吗
    还有 我看petshop里的DALFactory层也没有引用PetShop.SQLServerDAL层为什么
    System.Reflection.Assembly MyM= System.Reflection.Assembly.Load("PetShop.SQLServerDAL"); 
    就可以通过?