/// <summary> /// Rebuilds assembly given the dirty files. /// </summary> /// <param name="filesToCompile">Dirty files to be recompiled in new assembly.</param> /// <returns>Path of the new assembly.</returns> private string rebuildAssembly(List <string> filesToCompile) { if (project.IsStartable) { NewAssemblyName = project.AssemblyName + "_enc.exe"; } else { NewAssemblyName = project.AssemblyName + "_enc.dll"; } string path = TemporaryPath + NewAssemblyName; CompilerErrors errs = CSharpBackgroundCompiler.RecompileWithName(path, filesToCompile); CompileSuccessful = (errs != null && !errs.HasErrors); WorkbenchSingleton.SafeThreadAsyncCall( delegate() { if (!CompileSuccessful && errs != null) { foreach (CompilerError err in errs) { BuildError error = new BuildError(err.FileName, err.Line, err.Column, err.ErrorNumber, err.ErrorText); error.IsWarning = err.IsWarning; TaskService.Add(new Task(error)); } } else { TaskService.Clear(); } } ); return(path); }
public void ComilerErrors(Document doc, System.CodeDom.Compiler.CompilerErrorCollection Errors) { //delete all previous compiler errors string fileName = ""; foreach (ListViewItem lvExisting in lvErrorList.Items) { if (Convert.ToInt32(lvExisting.SubItems[1].Text) > 0) //compiler Warnings and errors { fileName = lvExisting.SubItems[3].Text; doc = ParentSc.ShowFile(fileName); if (doc != null) { doc.HighlightRemove(Convert.ToInt32("0" + lvExisting.SubItems[4].Text), Convert.ToInt32("0" + lvExisting.SubItems[5].Text)); } lvExisting.Remove(); } } //Add Errors ListViewItem lvItem; if (Errors.HasErrors || Errors.HasWarnings) { foreach (System.CodeDom.Compiler.CompilerError e in Errors) { int lineNo = (e.Line - 1); int ColNo = (e.Column - 1); lineNo = lineNo < 0 ? 0 : lineNo; ColNo = ColNo < 0 ? 0 : ColNo; fileName = System.IO.Path.GetFileName(e.FileName); if (e.IsWarning) { lvItem = new ListViewItem(new string[] { "", "2", e.ErrorText, fileName, lineNo.ToString(), ColNo.ToString() }); lvItem.StateImageIndex = 2; } else { lvItem = new ListViewItem(new string[] { "", "1", e.ErrorText, fileName, lineNo.ToString(), ColNo.ToString() }); lvItem.StateImageIndex = 3; } lvItem.Tag = fileName + "-" + lineNo.ToString() + "-" + ColNo.ToString(); lvErrorList.Items.Add(lvItem); doc = ParentSc.ShowFile(fileName); if (doc != null) { doc.HighlightError(lineNo, ColNo, e.IsWarning, e.ErrorText); } } } UpdateSummary(); }
void IScriptEditor.HighlightErrors(System.CodeDom.Compiler.CompilerErrorCollection errors) { if (errors.Count == 0) { return; } int line = Math.Max(0, errors[0].Line - 1); int column = Math.Max(0, errors[0].Column - 1); BeginInvoke(new Action <int, int>(SetCaretPositionCore), line, column); }
public string FormatErrors(System.CodeDom.Compiler.CompilerErrorCollection errorColl) { string retVal = ""; foreach (System.CodeDom.Compiler.CompilerError error in errorColl) { retVal += FormatError(error); } return(retVal); }
public static void ShowTemplateHostErrors(System.CodeDom.Compiler.CompilerErrorCollection errors) { if (errors.Count == 0) { return; } TaskService.Errors.Clear(); foreach (System.CodeDom.Compiler.CompilerError err in errors) { TaskService.Errors.Add(new Task(err.FileName, err.ErrorText, err.Column, err.Line, err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error)); } TaskService.ShowErrors(); }
private void RunCode(Assembly assembly) { try { Type[] types = assembly.GetExportedTypes(); foreach (Type type in types) { Type interfaceType = type.GetInterface("NOToolsTests.CSharpTextEditor1.IScriptComponent"); if (null != interfaceType) { IScriptComponent component = assembly.CreateInstance(type.FullName) as IScriptComponent; component.Execute(); return; } } } catch (Exception exception) { System.CodeDom.Compiler.CompilerErrorCollection collection = new System.CodeDom.Compiler.CompilerErrorCollection(); System.CodeDom.Compiler.CompilerError error = new System.CodeDom.Compiler.CompilerError("", 0, 0, "0", exception.Message); collection.Add(error); codeEditorControl1.ShowErrors(collection); } }
private void RunCode(Assembly assembly) { try { Type[] types = assembly.GetExportedTypes(); foreach (Type type in types) { Type interfaceType = type.GetInterface("NOToolsTests.CSharpTextEditor1.IScriptComponent"); if (null != interfaceType) { IScriptComponent component = assembly.CreateInstance(type.FullName) as IScriptComponent; component.Execute(); return; } } } catch (Exception exception) { System.CodeDom.Compiler.CompilerErrorCollection collection = new System.CodeDom.Compiler.CompilerErrorCollection(); System.CodeDom.Compiler.CompilerError error = new System.CodeDom.Compiler.CompilerError("", 0, 0, "0", exception.Message); collection.Add(error); codeEditorControl1.ShowErrors(collection); } }
/// <summary> /// Logs the errors passed from the engine. /// </summary> public void LogErrors(System.CodeDom.Compiler.CompilerErrorCollection errors) { this.errors = errors; }
private void GetExceptions() { string strInnerErrorType = ""; string strErrorTrace = ""; string strErrorLine = ""; string strErrorFile = ""; string strErrorPage = System.Web.HttpContext.Current.Request.PhysicalPath; AppendTableHeader(); Sb.Append("<tr>"); Sb.Append("<td colspan=2><h3>Exceptions</h3></td>"); Sb.Append("</tr>"); while (_CurrentException != null) { Exception exInnerError = _CurrentException; if (exInnerError != null) { strInnerErrorType = exInnerError.GetType().ToString(); switch (strInnerErrorType) { // ascx/aspx compile error case "System.Web.HttpCompileException": System.CodeDom.Compiler.CompilerErrorCollection colErrors = ((System.Web.HttpCompileException)exInnerError).Results.Errors; if (colErrors.Count > 0) { strErrorLine = colErrors[0].Line.ToString(); strErrorFile = colErrors[0].FileName; strErrorMessage = colErrors[0].ErrorNumber + ": " + colErrors[0].ErrorText; } break; // any other error like XML parsing or bad string manipulations default: System.Diagnostics.StackTrace stError = new System.Diagnostics.StackTrace(exInnerError, true); for (int i = 0; i < stError.FrameCount; i++) { if (stError.GetFrame(i).GetFileName() != null) { strErrorLine = stError.GetFrame(i).GetFileLineNumber().ToString(); strErrorFile = stError.GetFrame(i).GetFileName(); strErrorMessage = exInnerError.Message; break; } } if (strErrorFile == "") { strErrorMessage = "Untrapped Exception: " + exInnerError.Message; strErrorFile = "Unknown"; } break; } strErrorTrace = exInnerError.StackTrace; FullTrace += strErrorTrace; } else { strErrorMessage = _CurrentException.Message; strErrorTrace = _CurrentException.StackTrace; strErrorFile = "Unknown"; } if (strErrorMessage.IndexOf("Application is restarting") > -1) { System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.Buffer = false; System.Web.HttpContext.Current.Response.Write("Error, Site is restarting. Try again later."); _SendMail = false; System.Web.HttpContext.Current.Response.Flush(); System.Web.HttpContext.Current.Response.End(); } if ((strInnerErrorType != null) && (strInnerErrorType.Trim().Length > 0)) { AppendTableRow("Type", strInnerErrorType.ToString(), true); } if ((strErrorMessage != null) && (strErrorMessage.Trim().Length > 0)) { AppendTableRow("Message", strErrorMessage.ToString(), true, "color:red;"); } if ((strErrorTrace != null) && (strErrorTrace.Trim().Length > 0)) { AppendTableRow("StackTrace", strErrorTrace.ToString().ToString().Replace("\n", "<br />"), true); } if ((strErrorFile != null) && (strErrorFile.Trim().Length > 0)) { AppendTableRow("Error File", CreateAnchor(strErrorFile.ToString()), true); } if ((strErrorLine != null) && (strErrorLine.Trim().Length > 0)) { AppendTableRow("Error Line", strErrorLine.ToString(), true); } Sb.Append("<tr>"); Sb.Append("<td colspan2> </td>"); Sb.Append("</tr>"); _CurrentException = _CurrentException.InnerException; } AppendTableFooter(); AppendHr(); }
public static void GetExceptions(Exception oCurrentException, ErrorTracker.ErrorInfo oErrorInfo) { string sFullTrace = string.Empty; string strInnerErrorType = string.Empty; string strErrorTrace = string.Empty; string strErrorLine = string.Empty; string strErrorFile = string.Empty; string strErrorMessage = string.Empty; string strErrorPage = System.Web.HttpContext.Current.Request.PhysicalPath; StringBuilder oSB = new StringBuilder(); AppendTableHeader(oSB); oSB.Append("<tr>"); oSB.Append("<td colspan=2><h3>Exceptions</h3></td>"); oSB.Append("</tr>"); bool bFirstStepDown = true; while (oCurrentException != null) { Exception exInnerError = oCurrentException; if (exInnerError != null) { strInnerErrorType = exInnerError.GetType().ToString(); switch (strInnerErrorType) { // ascx/aspx compile error case "System.Web.HttpCompileException": System.CodeDom.Compiler.CompilerErrorCollection colErrors = ((System.Web.HttpCompileException)exInnerError).Results.Errors; if (colErrors.Count > 0) { strErrorLine = colErrors[0].Line.ToString(); strErrorFile = colErrors[0].FileName; strErrorMessage = colErrors[0].ErrorNumber + ": " + colErrors[0].ErrorText; } break; // any other error like XML parsing or bad string manipulations default: System.Diagnostics.StackTrace stError = new System.Diagnostics.StackTrace(exInnerError, true); for (int i = 0; i < stError.FrameCount; i++) { if (stError.GetFrame(i).GetFileName() != null) { strErrorLine = stError.GetFrame(i).GetFileLineNumber().ToString(); strErrorFile = stError.GetFrame(i).GetFileName(); strErrorMessage = exInnerError.Message; break; } } if (strErrorFile == "") { strErrorMessage = exInnerError.Message; strErrorFile = "Unknown"; } break; } strErrorTrace = exInnerError.StackTrace; sFullTrace += strErrorTrace; } else { strErrorMessage = oCurrentException.Message; strErrorTrace = oCurrentException.StackTrace; strErrorFile = "Unknown"; } if (strErrorMessage.IndexOf("This is an invalid webresource request.") > -1) { if (DisableTelerikWebResourceException) { throw new TelerikWebResourceException(); } } else if (strErrorMessage.IndexOf("Application is restarting") > -1) { throw new ApplicationStartException(); } if ((strInnerErrorType != null) && (strInnerErrorType.Trim().Length > 0)) { AppendTableRow(oSB, "Type", strInnerErrorType, true); } if ((strErrorMessage != null) && (strErrorMessage.Trim().Length > 0)) { AppendTableRow(oSB, "Message", strErrorMessage, true, "color:red;"); } if ((strErrorFile != null) && (strErrorFile.Trim().Length > 0)) { AppendTableRow(oSB, "Error File", CreateAnchor(strErrorFile), true); } if ((strErrorLine != null) && (strErrorLine.Trim().Length > 0)) { AppendTableRow(oSB, "Error Line", strErrorLine, true); } if ((strErrorTrace != null) && (strErrorTrace.Trim().Length > 0)) { AppendTableRow(oSB, "StackTrace", strErrorTrace.Replace("\n", "<br />"), true); } oSB.Append("<tr>"); oSB.Append("<td colspan2> </td>"); oSB.Append("</tr>"); if (bFirstStepDown) { oErrorInfo.Name = strInnerErrorType; oErrorInfo.ExceptionType = strInnerErrorType; oErrorInfo.ErrorLineNumber = string.Empty == strErrorLine ? 0 : Convert.ToInt32(strErrorLine); oErrorInfo.SourceFile = strErrorFile; oErrorInfo.Description = strErrorMessage; } oCurrentException = oCurrentException.InnerException; bFirstStepDown = false; } AppendTableFooter(oSB); AppendHr(oSB); // 1line if (strErrorTrace != null) { oErrorInfo.StackTrace = strErrorTrace.Replace("\n", "<br />"); } if ((oErrorInfo.Name == null) || (oErrorInfo.Name.Length == 0)) { oErrorInfo.Name = "Unknown Exception"; } oErrorInfo.ExceptionsDescription = oSB.ToString(); }
public CompilerErrorCollection(System.CodeDom.Compiler.CompilerErrorCollection value) { }
public void AddRange(System.CodeDom.Compiler.CompilerErrorCollection value) { }
public TemplateFormatException(System.CodeDom.Compiler.CompilerErrorCollection errors) { this._errors = errors; }
protected void Page_Load(object sender, EventArgs e) { int i = 0; while (true) { i++; try { Response.Clear(); ErrorManager.Initialize(Member.Null()); if (Utilities.isMobileBrowser()) { Utilities.MoveToSecure(); } DateTime startTime = DateTime.Now; string HTTP_Protocol = (Request.IsSecureConnection) ? "https://" : "http://"; Uri PageUri = new Uri(HTTP_Protocol + Request.Url.Host + Request.RawUrl); try { SqlConnection = new MySqlConnection("Server=localhost;Uid=root;Pwd=hl1vlAbR9a3Riu;database=blazegameshome5;Pooling=true;Min Pool Size=5;Max Pool Size=60;"); SqlConnection.Open(); } catch (MySql.Data.MySqlClient.MySqlException) { MySqlConnection.ClearAllPools(); SqlConnection = new MySqlConnection("Server=localhost;Uid=root;Pwd=hl1vlAbR9a3Riu;database=blazegameshome5"); SqlConnection.Open(); } #region Build PageEditor If Needed BlazeGames.Web.Core.Page PageEditor = new BlazeGames.Web.Core.Page(1, SqlConnection); if (PageEditor.Code != File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/bin/PageEditor.cs")) { PageEditor.Code = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/bin/PageEditor.cs"); System.CodeDom.Compiler.CompilerErrorCollection errors = PageEditor.Compile(); if (errors.Count >= 1) { ErrorManager.Error(errors[0].ErrorText); } } #endregion ErrorManager.Initialize(SqlConnection); string NewSessionKey = ""; while (true) { NewSessionKey = Guid.NewGuid().ToString(); MySqlCommand SessionVerifyQuery = new MySqlCommand("SELECT ID FROM members WHERE WebSessionKey=@WebSessionKey", SqlConnection); SessionVerifyQuery.Parameters.AddWithValue("@WebSessionKey", NewSessionKey); MySqlDataReader SessionVerifyReader = SessionVerifyQuery.ExecuteReader(); if (!SessionVerifyReader.Read()) { SessionVerifyReader.Close(); break; } else { SessionVerifyReader.Close(); continue; } } if (Request.Cookies["BlazeGames"] == null) { BGxCookie = new System.Web.HttpCookie("BlazeGames"); BGxCookie.Values.Add("WebSession", NewSessionKey); BGxCookie.Expires = DateTime.Now.AddDays(7); BGxCookie.Domain = ".blaze-games.com"; Response.Cookies.Add(BGxCookie); } else { BGxCookie = Request.Cookies["BlazeGames"]; System.Web.HttpCookie BGxCookieNew = new System.Web.HttpCookie("BlazeGames"); BGxCookieNew.Values.Add("WebSession", BGxCookie.Values["WebSession"]); BGxCookieNew.Expires = DateTime.Now.AddDays(7); BGxCookieNew.Domain = ".blaze-games.com"; Response.Cookies.Add(BGxCookieNew); BGxCookie = BGxCookieNew; } //Response.Write(BGxCookie.Values["WebSession"] + "<br />" + Request.UserHostAddress); //Response.End(); Member LoggedInMember; if (Utilities.GET("Account") != "" && Utilities.GET("Password") != "") { string Account = Utilities.GET("Account"), Password = Utilities.GET("Password"); if (Member.TryLoginWithPassword(Account, Password, SqlConnection)) { LoggedInMember = new Member(Account, SqlConnection); } else { LoggedInMember = new Member(BGxCookie.Values["WebSession"], Request.UserHostAddress, SqlConnection); } } else { LoggedInMember = new Member(BGxCookie.Values["WebSession"], Request.UserHostAddress, SqlConnection); } if (Utilities.POST("Account") != "" && Utilities.POST("Password") != "" && Utilities.POST("Act") == "Login" && !LoggedInMember.IsValid) { if (!Member.Login(Utilities.POST("Account"), Utilities.POST("Password"), BGxCookie.Values.Get("WebSession"), Request.UserHostAddress, SqlConnection)) { ErrorManager.Fatal("Login Failed!\r\n<a href='" + PageUri.AbsolutePath + "'>Go Back</a><script>setTimeout('location.href = \"" + PageUri.AbsolutePath + "\";', 2500);</script>", "Account: " + Utilities.POST("Account") + "<br />Hash: " + Member.HashPassword(Utilities.POST("Password"))); } else { LoggedInMember.Load(); ErrorManager.Initialize(LoggedInMember); ErrorManager.Message("Login Complete!\r\n<a href='" + PageUri.AbsolutePath + "'>Continue</a><script>setTimeout('location.href = \"" + PageUri.AbsolutePath + "\";', 2500);</script>"); } } else if (Utilities.GET("Act") == "Logout") { BGxCookie = new System.Web.HttpCookie("BlazeGames"); BGxCookie.Values.Add("WebSession", Guid.NewGuid().ToString()); BGxCookie.Domain = ".blaze-games.com"; BGxCookie.Expires = DateTime.Now.AddMonths(1); Response.Cookies.Add(BGxCookie); ErrorManager.Initialize(new Member("", "", SqlConnection)); ErrorManager.Message("Logout Complete!\r\n<a href='" + PageUri.AbsolutePath + "'>Go Back</a><script>setTimeout('location.href = \"" + PageUri.AbsolutePath + "\";', 2500);</script>"); } LoggedInMember.Load(); ErrorManager.Initialize(LoggedInMember); Logging Log = new Logging(SqlConnection, LoggedInMember); HttpHeader HttpHead = new HttpHeader(); Core.Events Event = new Core.Events(); PageSys = new DynamicPages(PageUri.AbsolutePath, SqlConnection, LoggedInMember, Log, HttpHead, Event); PageSys.onPageInitialize(); PageSys.onPageLoad(); string Buffer = ""; if (Utilities.isMobileApps()) { Buffer = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/MobileApps/index.txt"); } else if (Utilities.isMobileBrowser()) { Buffer = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Mobile/index.txt"); } else { Buffer = File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/" + HttpHead.Theme + "/index.txt"); } Buffer = Buffer.Replace("<!--{PageHeader}-->", HttpHead.ToString() + "\r\n<style type='text/css'>\r\n" + PageSys.CurrentPage.PageCSS + "\r\n</style>\r\n" + "<script type='text/javascript'>\r\n" + PageSys.CurrentPage.PageJS + "\r\n</script>"); Buffer = Buffer.Replace("<!--{PageContents}-->", PageSys.CurrentPage.PageHTML); Buffer = Buffer.Replace("<!--{PageCode}-->", PageSys.onPageReturn()); Buffer = Buffer.Replace("<!--{WIDGET_Clock}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Clock.txt")); if (LoggedInMember.IsValid) { Buffer = Buffer.Replace("<!--{WIDGET_Login}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Login_Member.txt")); } else { Buffer = Buffer.Replace("<!--{WIDGET_Login}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Login_Guest.txt")); } Buffer = Buffer.Replace("<!--{WIDGET_Social)-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Social.txt")); Buffer = Buffer.Replace("<!--{WIDGET_Posts}-->", File.ReadAllText(HttpContext.Current.Server.MapPath(".") + "/Themes/Default/Widgets/Posts.txt")); Buffer = Buffer.Replace("<!--{Time}-->", Utilities.GetDateTime()); Buffer = Buffer.Replace("<!--{Nickname}-->", LoggedInMember.Nickname); Buffer = Buffer.Replace("<!--{ProfileImage}-->", LoggedInMember.GetProfileImage()); Buffer = Buffer.Replace("<!--{Url_Secure)-->", Utilities.GetCurrentUrl(true)); Buffer = Buffer.Replace("<!--{PageName}-->", PageSys.PageURL); foreach (string ParamKey in HttpHead.ThemeParameters.Keys) { Buffer = Buffer.Replace("{" + ParamKey + "}", HttpHead.ThemeParameters[ParamKey]); } Buffer = Buffer.Replace("{ThemePath}", "/Themes/" + HttpHead.Theme + "/"); DateTime stopTime = DateTime.Now; TimeSpan duration = stopTime - startTime; SqlConnection.CancelQuery(100); SqlConnection.Close(); //SqlConnection.Dispose(); Response.Write(@"<!-- ------------------------------------------ ---- Blaze Games Web v5 Debug Console ---- ------------------------------------------ Script Execution Time: " + duration.Milliseconds + @"MS sqlConnection State: " + SqlConnection.State + @" --> "); Response.Write(Buffer); Response.Flush(); Response.End(); PageSys.onPageUnLoad(); break; } catch (Exception ex) { if (i == 5) { throw ex; } continue; } } }
public void LogErrors(System.CodeDom.Compiler.CompilerErrorCollection errors) { throw new NotImplementedException(); }