Assembly information can be accessed through the Assembly class in C#.
1. Allows access to meta elements of a given assembly, including methods that can load and execute the assembly;
2. Load an assembly: Use the static method Assembly. Load (assembly name) or Assembly.LoadFrom (assembly full path name);
3. Attributes:
FullName: Assembly display name;
3. Method:
GetTypes(): Get Types defined in the assembly.
TestAssembly.cs:
view plaincopy to clipboardprint?
using System; using System.Reflection;
namespace Magci.Test.Reflection
{ public class TestAssembly
{ public static void Main ()
{ //Load the assembly into the running process
Assembly ass = Assembly.Load("TestCustomAttributes");
Assembly ass1 = Assembly.LoadFrom(@"E:CODEdotNetC#9-ReflectionTestCustomAttributes .dll");
//Get the assembly display name
Console.WriteLine(ass1.FullName);
//Get the types defined in the assembly
Type[] types = ass.GetTypes ();
foreach (Type t in types)
{ Console.WriteLine(t.FullName);
} } } }