1

I am kind of new to Reflection and have gone through some basic examples, but I cannot figure out how to accomplish my goal.

I have a small console application which I want to call an assembly from. in this case the assembly is a Class Library Containing multiple classes and what I want to achieve is listing all of my classes with their children and parent classes.

       Assembly asm = Assembly.LoadFrom(@"C:\Sandbox\Functions\Bin\Debug\Functions.dll");

       Type T = asm.GetType();

So I have loaded the file but I am uncertain where to go now, how to use the metadata in order to access the necessary files and classes. Would appreciate some advice or references to other examples (Which I tried to search for).

  • What is your problem? What have you tried so far? – MiGro Jun 21 '17 at 07:17
  • So my issue is I want to know how to access the appropriate data like my class names etc. But I can't find documentation containing the correct methods I need to move forward. @MiGro –  Jun 21 '17 at 07:19
  • Assembly.GetTypes() will return you a list of types. From there you can move on. – thehennyy Jun 21 '17 at 07:21
  • 1
    @tjapple Here is a simple tutorial: https://dotnetcademy.net/Learn/4/Pages/1 – MiGro Jun 21 '17 at 07:25
  • also what I need thanks. @MiGro –  Jun 21 '17 at 07:29

1 Answers1

0

Just google what specifically you are trying to do, pretty much everything you want to do with reflection is on stack overflow in some shape or form...

Assembly asm = Assembly.LoadFrom(@"C:\Sandbox\Functions\Bin\Debug\Functions.dll");

foreach (Type t in asm.GetTypes())
{
    //... t.FullName
    //... t.GetAllBaseClassesAndInterfaces
    //... t.GetNestedTypes 
}

https://stackoverflow.com/a/1315668/588734

Given a C# Type, Get its Base Classes and Implemented Interfaces

Eamonn McEvoy
  • 8,876
  • 14
  • 53
  • 83