public ScriptHandle Compile(string[] Sources, ref ScriptCompilerError[] Errors) { ScriptHandle handle = ScriptHandle.Invalid(); CompilerResults results = CodeProvider.CompileAssemblyFromSource(CompilerParams, Sources); if (results.Errors.HasErrors) { var errorList = new List <ScriptCompilerError>(); foreach (CompilerError error in results.Errors) { ScriptCompilerError compileError; compileError.Error = error.ErrorText; compileError.Line = error.Line; compileError.FileName = error.FileName; errorList.Add(compileError); } Errors = errorList.ToArray(); } else { handle = new ScriptHandle(results.CompiledAssembly); } return(handle); }
private void button3_Click_2(object sender, EventArgs e) { var sources = new string[] { txCsharpScript.Text }; ScriptCompilerError[] errors = null; userScript = scriptMan.Compile(sources, ref errors); label7.Text = $"Compiled: {userScript.IsValid}"; listBox1.BeginUpdate(); listBox1.Items.Clear(); if (!userScript.IsValid) { foreach (var error in errors) { listBox1.Items.Add($"{error.Error}"); } } listBox1.EndUpdate(); }