/// <summary> /// Executes the processed code from Process() function. /// </summary> /// <param name="errors">If execution was not successful, returns CompilerErrorCollection or Exception</param> /// <returns>Values to put in each code segment (output) or null if there were errors</returns> public string[] Execute(out object errors) { errors = null; segmentsOutput = new string[segmentNum]; for (int i = 0; i < segmentNum; i++) { segmentsOutput[i] = ""; } segmentNum = -1; CSHARP.CSharpCodeProvider provider = new CSHARP.CSharpCodeProvider(); CompilerParameters parms = new CompilerParameters(); parms.GenerateInMemory = true; parms.TreatWarningsAsErrors = false; parms.TempFiles = new TempFileCollection(Environment.GetEnvironmentVariable("TEMP"), true); parms.IncludeDebugInformation = true; parms.ReferencedAssemblies.Add(Assembly.GetEntryAssembly().Location); try { string[] assms = File.ReadAllText(ConfigurationManager.SETTINGS["ASSEMBLIES"]).Split(new char[] { '\n' }); for (int i = 0; i < assms.Length; i++) { parms.ReferencedAssemblies.Add(assms[i].Trim()); } } catch { } CompilerResults res = provider.CompileAssemblyFromSource(parms, FinalCode); if (res.Errors.HasErrors) // Handling compiler errors { errors = res.Errors; return(null); } Assembly ass = res.CompiledAssembly; Type prog = ass.GetType("LWASP_Console.WebApp"); MethodInfo main = prog.GetMethod("Rain"); try { main.Invoke(null, new object[] { connection, connection.queryString, connection.formData, connection.PostData() }); } catch (Exception exx) { errors = exx != null ? exx.InnerException ?? exx : new Exception("LWASP Error"); return(null); } return(segmentsOutput); }