Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Created September 8, 2011 18:37
Show Gist options
  • Save qpfiffer/1204229 to your computer and use it in GitHub Desktop.
Save qpfiffer/1204229 to your computer and use it in GitHub Desktop.
Fun times with C# Reflection.
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace DLL_Pirate
{
class Program
{
static void Main(string[] args)
{
Assembly toPirate;
if (System.IO.File.Exists("AVEInternals.dll"))
{
toPirate = Assembly.LoadFrom("AVEInternals.dll");
}
else
{
Console.WriteLine("ARG, YE FILE DONT EXIST!");
Console.ReadLine();
return;
}
Type[] typeArray = null;
try
{
typeArray = toPirate.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
Console.WriteLine("EXCEPTION, YAR! HERE IT BE: " + ex.Message);
foreach (Exception exception in ex.LoaderExceptions)
{
Console.WriteLine("THESE SWINE-LOVIN' LOADER EXCEPTIONS: " + exception);
}
Console.ReadLine();
}
if (typeArray != null)
{
Console.WriteLine("BLLEALSLFLSLAFSDLRARAGAGAGAGGEGE!");
foreach (Type type in typeArray)
{
Console.WriteLine(type);
}
//ConstructorInfo[] cStructs = toPirate.GetType("AVE.Downloader").GetConstructors();
//foreach (ConstructorInfo cStructor in cStructs)
//{
// Console.WriteLine(cStructor);
//}
}
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment