using System.Windows.Forms;
private static SynchronizationContext context = null;
private static MethodInfo showMessageMethod;
private static Form formInstance;
static void Main(string[] args)
var assemblyPath = @"C:\Users\alexandru.clontea\Source\Repos\ConsoleApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe";
var assembly = Assembly.LoadFrom(assemblyPath);
var allControlTypes = assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Form)));
var form1Type = allControlTypes.Single(c => c.Name == "Form1");
var formInstanceHandle = Activator.CreateInstanceFrom(assemblyPath, form1Type.ToString());
var allMethods = form1Type.GetMethods();
showMessageMethod = allMethods.Single(m => m.Name == "ShowMessage" && m.GetParameters().Any());
formInstance = (Form)formInstanceHandle.Unwrap();
context = SynchronizationContext.Current;
((Form)formInstance).Shown += form_Shown;
Application.EnableVisualStyles();
Application.Run(formInstance);
private static void form_Shown(object sender, EventArgs e)
showMessageMethod.Invoke(formInstance, new object[] { "eureeeka!" });