I'm trying to make a Windows Form Application, that can compile another Windows Form Application. But I'm getting a couple of errors, set in the CodeEntryPointMethod (CodeDom), when i'm setting up the default Main method to run the Winform.
The best overloaded method match for 'System.Windows.Forms.Application.Run(System.Windows.Forms.Form)' has some invalid arguments
Argument '1' cannot convert from 'kjpUnityGameLauncherTemplate.Launcher' to 'System.Windows.Forms.Form'
The CodeEntryPointMethod looks like this:
CodeEntryPointMethod start = new CodeEntryPointMethod();
CodeMethodInvokeExpression mainClassSetup = new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression(typeof(System.Windows.Forms.Application)), "Run",
new CodeObjectCreateExpression(typeof(kjpUnityGameLauncherTemplate.Launcher)));
start.Statements.Add(mainClassSetup);
My 'Launcher' class/Form:
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace kjpUnityGameLauncherTemplate
{
public partial class Launcher : Form
{
public Launcher()
{
InitializeComponent();
}
private void Launcher_Load(object sender, EventArgs e)
{
label1.Text = "It works!";
}
}
}