反射

static void  CheckBasePage()
        {
            Assembly assembly = Assembly.GetAssembly(typeof(BasePage));    
          
            Module module = assembly.ManifestModule;
            Type[] types = module.GetTypes();          
            foreach (Type t in types)
            {
                try
                {
                    if (t.IsSubclassOf(typeof(System.Web.UI.Page)))
                    {
                        if (!t.IsSubclassOf(typeof(BasePage)))
                        {
                            string aa = t.ToString() + "没有继承该类";
                            Console.WriteLine(aa);                           
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "-" + ex.StackTrace);
                }

            }

            //Assembly a = Assembly.LoadFile(@" ");
            //Type[] type = a.GetTypes();
            //foreach (Type t in type)
            //{
              
            //    try
            //    {
                  
            //        if (t.IsSubclassOf(typeof(System.Web.UI.Page)))
            //        {
            //            BasePage o = (BasePage)a.CreateInstance(t.FullName);
            //            object value = t.GetProperty("Guid").GetValue(o, null);
            //        }
            //    }
            //    catch
            //    { }
            //}
        }

原文地址:https://www.cnblogs.com/zwei1121/p/1004638.html