そのため、C#/CodeDom スクリプトを使用して実行可能ファイルをコンパイル/ビルドしようとしています。
Application.Run() のようないくつかのメソッドを使用して実際に Windows フォーム アプリケーションを実行するために、新しいアプリケーション (コンパイルするアプリケーション) をメイン メソッドに設定しようとしています。
私が得たエラー:
プリミティブ型 kjpUnityGameLauncherTemplate.Launcher が無効です。したがって、CodeObjectCreateExpression の使用を検討する必要があります。
メソッドを実行するために、これが私が書くべきものだと言われたので、私には理解できません。また、CodeEntryPointMethod には既定で Main メソッドが既に含まれているため、「Application.Run()」メソッドなどを追加するだけでよいとのことですが、それは私が聞いた話です。
CodeTypeDeclaration class1 = new CodeTypeDeclaration("RunLauncher");
CodeEntryPointMethod start = new CodeEntryPointMethod();
CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("Application"), "EnableVisualStyles");
CodeMethodInvokeExpression cs2 = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("Application"), "SetCompatibleTextRenderingDefault", new CodePrimitiveExpression(false));
CodeMethodInvokeExpression cs3 = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("Application"), "Run", new CodePrimitiveExpression(new Launcher()));
start.Statements.Add(cs1);
start.Statements.Add(cs2);
start.Statements.Add(cs3);
class1.Members.Add(start);
Application.Run() で実行される "new Launcher()" は、Form1 クラスを実行してアプリケーションを実行する通常の Program.cs スクリプトがある場合とまったく同じです。少なくともそれが理にかなっていることを願っています。