private void CompileAndExecute(string file, string[] args, string[] strReferenceAssembliesToAdd, IScriptManagerCallback callback) { try { //Create an AppDomain to compile and execute the code //This enables us to cancel the execution if needed executionDomain = AppDomain.CreateDomain("ExecutionDomain"); IScriptManager manager = (IScriptManager)executionDomain.CreateInstanceFromAndUnwrap(typeof(BaseApp).Assembly.Location, typeof(ScriptManager).FullName); manager.CompileAndExecuteFile(file, args, strReferenceAssembliesToAdd, this); } catch (UnsupportedLanguageExecption e) { ShowErrorMessage("UnsupportedLanguage (from resource):" + e.Extension); } catch (AppDomainUnloadedException e) { System.Diagnostics.Trace.WriteLine(e.Message); } catch (Exception e) { ShowErrorMessage(e.Message); } TerminateExecutionLoop(); }