//编译运行 public void MakeAndRun() { string errorMsg = string.Empty; if (CompileCode(ref errorMsg)) { try { var doc = InteractiveManager.GetCurrentDocument(); string CSharpContent = doc.GetText().ToString(); var scriptEngine = InteractiveManager.GetScriptEngine(); session = scriptEngine.CreateSession(); session.Execute(CSharpContent); Formatter.WriteObject("Make all success." + DateTime.Now.ToString()); } catch (Exception ex) { Formatter.WriteError(ex); } } else { Formatter.Clear(); Formatter.WriteObject(errorMsg); MessageBox.Show("Compile Failed !", "Tips", MessageBoxButton.OK, MessageBoxImage.Error); } }