Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get list of the classes in casual assembly
Message
From
12/03/2010 08:18:33
 
 
To
12/03/2010 07:34:41
Vladimir Zhuravlev
Institute of the Physics of Earth,Russia
Moscow Region, Russia
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01453908
Message ID:
01454140
Views:
32
>Gregory< what I have missed
>I have
>
> public string GetModInfo(string Assemblyname)
> {
> string vbTab = " ";
> var list = (from m in Assembly.Load(Assemblyname).GetModules() select m.GetTypes().Where(x => x.IsClass)).ToList();
> foreach (var className in list) { vbTab = vbTab + className.ToString();
> }
> return vbTab;
> }
>call it with like
>GetModInfo("System.Windows.Forms") from my class
>It tells to me - could not find assemby
>More long code with - {var assembly = Assembly.Load(assemblyName) ... works fine
>Sure, I have referencies to System.Data.Linq and System.Xml.Linq

My version returns a list Modules each containing a list of Classes. You'd need something like:
 List<IEnumerable<Type>> list = 
 (from m in Assembly.Load(Assemblyname).GetModules() select m.GetTypes().Where(x => x.IsClass)).ToList();

foreach ( IEnumerable<Type> t in list)
        {
              foreach (Type className in t)
              {
                 Console.WriteLine("{0}", className.FullName);
               }
        }
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform