Skip to content

Instantly share code, notes, and snippets.

@gogsbread
Last active December 10, 2015 01:08
Show Gist options
  • Save gogsbread/4355851 to your computer and use it in GitHub Desktop.
Save gogsbread/4355851 to your computer and use it in GitHub Desktop.
Quickly invoke a method using Reflection and power of Roslyn CTP.. Very helpful if you want to execute methods inside a framework library for debugging.
//Assume you have a method, m() in class "Framework" inside framework.dll
// Fire C# interpreter(a.k.a Roslyn CTP) from your Visual Studio and type the following lines of code.
using System.Reflection;
Assembly assembly = Assembly.LoadFrom(@"path\to\assembly\framework.dll");
Type framework = assembly.GetType("Framework");
ConstructorInfo cFramework = framework.GetConstructor(Type.EmptyTypes);
object oFramework = cFramework.Invoke(new object[] { });
MethodInfo mMethod = framework.GetMethod("m");
mMethod.Invoke(oFramework,new object[] { })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment