如上图
我在program.cs里加入了记录无法处理异常的代码,但是没有记录任何日志        static Program()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
        }        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            string strException = string.Format("{0}发生系统异常。\r\n{1}\r\n\r\n\r\n", DateTime.Now, e.ExceptionObject.ToString());
            File.AppendAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SystemException.log"), strException);
        }

解决方案 »

  1.   


    那就是线程的原因http://www.bianceng.cn/Programming/csharp/201107/27675.htm
      

  2.   

    程序里有些地方我使用了lock(this)
    是不是只要线程访问的资源都最好lock一下呢?
      

  3.   


    请问 winform 也会有 缓存 的么??
      

  4.   

    检查了一下,程序里只有一个地方使用了lock关键字,是为了防止执行这段代码时全局变量值被别的代码更改但只有一个线程会访问到这段代码,另一个线程不会执行这段代码,应该不会线程死锁吧
      

  5.   


    加了很多错误日志,还在program.cs里加了对无法处理异常的记录日志。但都没有捕获到。
      

  6.   

    帮 mizuho_2006 大哥顶1下。
      

  7.   

    我程序里还用了2个线程定时器(System.Threading.Timer),是不是也会造成线程死锁?有个线程定时器和另外一个线程里都调用了DisplaySendString方法,用来显示字符串到RichTextBox中,会不会造成线程死锁呢?