>I need to get list of classes names from any taken particular assembly by code
>For example for system.windows.forms
>The assymbly name should be entry method parameter
>I tried to write this method using my old samples of using reflection for getting list of methods, events , properties
>
>public string GetModInfo(string Assemblyname)
>
>{
>
>Assembly a = Assembly.LoadWithPartialName(Assemblyname);
>
>** This string now gives error - this is old method of load, code is depricated
>** use load instead ???
>**
>Module M = a.GetModules();
>** this also gives error
>Type T = M.GetType();
>for each( ....
>
>*********************************************************
>I looked many samples of using reflection on different sites and did not find the code
Vladimir,
Would this give you a start ?
static void Main()
{
var list = GetAssemblyClasses("GregoryAdam.Base");
foreach (var className in list)
{
Console.WriteLine("{0} : {1}", className.IsClass ? "Class" : "Struct", className.FullName);
}
Console.ReadLine();
}
public static List<Type> GetAssemblyClasses(string assemblyName)
{
var assembly = Assembly.Load(assemblyName);
List<Type> classList = new List<Type>();
foreach (var module in assembly.GetModules())
{
foreach (var type in module.GetTypes())
{
if (!type.IsClass ) // && !type.IsValueType)
continue;
classList.Add(type);
}
}
return classList;
}
}
Gregory