public void StartAssemblyResolve() { XmlConfig config = GetRunSourceConfig(); if (config != null) { AssemblyResolve.TraceAssemblyResolve = config.Get("TraceAssemblyResolve").zTryParseAs(false); //AssemblyResolve.TraceAssemblyLoad = config.Get("TraceAssemblyLoad").zTryParseAs(false); //AssemblyResolve.UpdateAssembly = config.Get("UpdateAssembly").zTryParseAs(false); ; //AssemblyResolve.UpdateSubDirectory = config.Get("UpdateAssemblySubDirectory", AssemblyResolve.UpdateSubDirectory); ; //AssemblyResolve.TraceUpdateAssembly = config.Get("TraceUpdateAssembly").zTryParseAs(false); } AssemblyResolve.Start(); }
private void RunCode_v1(string code, bool useNewThread = true, bool compileWithoutProject = false) { if (code == "") { return; } bool bError = false; if (_runCodeThread != null) { throw new PBException("error program already running"); } bool bOk = false; _runCodeChrono = new Chrono(); try { AssemblyResolve.Stop(); AssemblyResolve.Clear(); _refreshRunSourceConfig = true; _refreshProjectConfig = true; IGenerateAndExecute generateAndExecute = GetGenerateAndExecuteManager().New(); _GenerateCodeAndCompile_v2(generateAndExecute, code, compileWithoutProject); if (generateAndExecute.Compiler.HasError()) { return; } MethodInfo runMethod = generateAndExecute.GetAssemblyRunMethod(); MethodInfo initMethod = generateAndExecute.GetAssemblyInitMethod(); MethodInfo endMethod = generateAndExecute.GetAssemblyEndMethod(); AssemblyResolve.Start(); if (useNewThread) { _runCodeThread = new Thread(new ThreadStart(() => _Run(runMethod, initMethod, endMethod))); _runCodeThread.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture; _runCodeThread.SetApartmentState(ApartmentState.STA); _runCodeThread.Start(); } else { Trace.WriteLine("execute on main thread"); _Run(runMethod, initMethod, endMethod); } bOk = true; } catch { bError = true; throw; } finally { if (!bOk && EndRun != null) { EndRun(bError); } } }