我收到以下"Attempted to read or write protected memory"
错误richTextBox_Console.AppendText
public void ConsoleWriteLine(string formatedText, bool urgent = false)
{
try
{
if (richTextBox_Console.InvokeRequired)
{
richTextBox_Console.BeginInvoke(new ConsoleWriteDelegate(ConsoleWriteLine), formatedText, urgent);
return;
}
else
{
if (!tabPage_Console.Focused && urgent)
tabPage_Console.Text = "Console(!)";
richTextBox_Console.AppendText(formatedText + Environment.NewLine);
}
}
catch (Exception Exc)
{
Testing.ExceptionHandler.HandleException(Exc);
}
}
public static MainForm View;
[STAThread]
static void Main()
{
FlatfileDB.Load();
LoadDatabase();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
View = new MainForm();
Application.Run(View);
}
public static void HandleException(string Exc)
{
try
{
using (StreamWriter writer = new StreamWriter("Exceptions.txt", true))
{
writer.WriteLine(string.Format("[{0}] \r\n{1}\r\n", DateTime.Now.ToString(), Exc.ToString()));
writer.Flush();
}
Program.View.ConsoleWriteLine("Exception has been handled. See Exceptions.txt", true);
}
catch { }
}
关于为什么会发生这种情况的任何解释都会很棒。
- 请注意,此错误不会立即发生,而是在几个小时内发生的。
- 我正在使用网络 4.5