コード例 #1
0
 /*********************************  异常处理  **********************************/
 /// <summary>
 /// 处理异常
 /// </summary>
 /// <param name="ex"></param>
 /// <param name="exSource"></param>
 /// <param name="proxy"></param>
 private static void HandleException(Exception ex, ExceptionSources exSource, bool proxy = true)
 {
     try
     {
     }
     catch (Exception ex1)
     { }
 }
コード例 #2
0
 private static void OnHandedExceptionProxy(Exception exception, ExceptionSources exSource, EnumErrorHandle handle)
 {
     try
     {
         var handler = _onExceptionEventHandler;
         if (handler != null)
         {
             handler(exception, handle, exSource);
         }
     }
     catch (Exception e)
     {
         HandleException(e, exSource, false);
     }
 }
コード例 #3
0
        /// <summary>
        /// 处理致命错误
        /// </summary>
        private static void HandleFatal(ExceptionSources source, IntPtr exceptionPointer, Exception hex = null)
        {
            try
            {
                int lastErrorCode = 0;
                if (exceptionPointer != IntPtr.Zero)
                {
                    var exInfo = Marshal.PtrToStructure <EXCEPTION_POINTERS>(exceptionPointer);
                    lastErrorCode = Marshal.ReadInt32(exInfo.ExceptionRecord.ExceptionCode);
                }
                StringBuilder error = new StringBuilder();
                error.AppendLine("系统意外崩溃,您可以尝试重启程序,或者联系技术支持");
                error.AppendLine("参考错误:0x" + (lastErrorCode == 0 ? Marshal.GetExceptionCode() : lastErrorCode).ToString("X8"));
                error.AppendLine("错误线程:0x" + ThreadHelper.GetCurrentThreadID());
                error.AppendLine("错误来源:" + source);
                error.AppendLine("内存占用:" + Environment.WorkingSet / 1024 + "KB");
                if (hex != null)
                {
                    error.AppendLine("附加信息:\n" + hex.StackTrace);
                }
                else
                {
                    error.AppendLine("附加信息:\n" + new StackTrace());
                }

                Log.Error(error.ToString());
                try
                {
                    Log.Error("Log dump start...");
                    DumpLogger.Write(string.Format("{0}.{1}", DateTime.Now.ToFileTime(), Guid.NewGuid().ToString()), exceptionPointer);
                    Log.Error("Log dump succ");
                }
                catch (Exception ex)
                {
                    Log.Error("log dump failed", ex);
                }
            }
            catch (Exception ex) { }
        }