Last active
December 10, 2015 01:08
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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