How to get useful information about the currently assembly

Having your application be aware of itself with reflection is quite powerful, e.g. being able to know when new .dlls are added, reacting to its internal classes and methods that build it up. This code gets you started peeking into the assembly itself.

firstReflect

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace DynamicAssembly2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Assembly.GetExecutingAssembly().FullName);

List<Type> types = Assembly.GetExecutingAssembly().GetTypes().ToList<Type>();
foreach (Type type in types)
{
Console.WriteLine(“–“);
Console.WriteLine(“type.FullName = {0}”, type.FullName);
Console.WriteLine(“type.Name = {0}”, type.Name);
Console.WriteLine(“type.BaseType = {0}”, type.BaseType);
Console.WriteLine(“type.Module = {0}”, type.Module);
Console.WriteLine(“type.Namespace = {0}”, type.Namespace);
Console.WriteLine(“type.GUID = {0}”, type.GUID);
}
Console.ReadLine();
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: