我用3层做的一个asp项目,我要在UI层里面反射出里面所有的类,为什么我用
Assembly ass = Assembly.GetExecutingAssembly();
// Assembly ass = Assembly.GetCallingAssembly();
foreach (Type type in ass.GetTypes())
{
//JScript.Alert(type.Name.ToString());
if (type.IsClass)
{string name=type.Name.ToString();
Response.WreteLine(name); }
}为什么有时候得到的多,有时候得到的少, 

解决方案 »

  1.   

    路过 绑定~
    这几天刚好看反射。好像GetType方法还支持参数的
      

  2.   

    怎么会不一样呢 - -习惯这样用 public static readonly string currentAssemblyName = Assembly.GetAssembly(typeof(当前类名)).ToString().Split(',')[0]; public static CategoriesDB CreateCategoriesDB()
     {
          string className = ConfigurationManager.AppSettings["CategoriesDB"];
          return (CategoriesDB)System.Reflection.Assembly.Load(currentAssemblyName).CreateInstance(className);
     }
      

  3.   

    3楼可以
    如果是泛型,可以参考
    http://www.cnblogs.com/downmoon/archive/2008/09/01/1281118.html
      

  4.   

    参考
    http://www.cnblogs.com/goody9807/archive/2005/11/10/273261.html
    http://www.cnblogs.com/saptechnique/archive/2008/03/28/1127834.html