-1

Visual Studio のような小さなイミディエイト ウィンドウを作成しています。Textedit でテキストをコンパイルしようとするだけです。今私の質問: 実行中のプログラムのスコープに入るにはどうすればよいですか? プログラムの値やリストを変更することはできますか? それは私の現在のコンパイルコードです:

    private void SimpleButtonCompileClick(object sender, EventArgs e)
    {
        CompilerParameters compilerParameters = new CompilerParameters();
        compilerParameters.GenerateExecutable = true;
        compilerParameters.GenerateInMemory = true;
        compilerParameters.TreatWarningsAsErrors = true;
        compilerParameters.CompilerOptions = "/nowarn:1633";
        String sourceCode = "";
        string pattern =
                "\\s*#pragma\\s+reference\\s+\"(?<path>[^\"]*)\"\\s*";
        System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match(sourceCode, pattern);
        if (match.Success)
            compilerParameters.ReferencedAssemblies.Add(match.Groups["path"].Value);
        // Specify .NET version
        Dictionary<string, string> providerOptions =
                new Dictionary<string, string>();
        providerOptions.Add("CompilerVersion", "v3.5");
        CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions);
        // Compile source           
        CompilerResults results = provider.CompileAssemblyFromSource(compilerParameters, new string[] {sourceCode});
        // Show errors
        if (results.Errors.HasErrors)
        {
            String errorString = "";
            foreach (var err in results.Errors)
                errorString += err + "\n";
            XtraMessageBox.Show(errorString);
        }
        else
        {
            // Invoke compiled assembly's entry point
            results.CompiledAssembly.EntryPoint.Invoke
                    (null, new object[0] {});
        }
    }
4

1 に答える 1