C WINFORM 捕獲全域性異常

2022-05-10 09:59:10 字數 1467 閱讀 4557

using

system;

using

system.collections.generic;

using

system.io;

using

system.linq;

using

system.threading.tasks;

using

system.windows.forms;

namespace

catch

(exception ex)

\r\n異常訊息:\r\n異常資訊:\r\n",

ex.gettype().name, ex.message, ex.stacktrace);

}else

", ex);

}writelog(str);

messagebox.show(

"", "

系統錯誤

", messageboxbuttons.ok, messageboxicon.error);}}

//////

///做法很多,可以是把出錯詳細資訊記錄到文字、資料庫,傳送出錯郵件到作者信箱或出錯後重新初始化等等

///這就是仁者見仁智者見智,大家自己做了。

/// ///

///static

sender, system.threading.threadexceptioneventargs e)

\r\n異常訊息:\r\n異常資訊:\r\n",

error.gettype().name, error.message, error.stacktrace);

}else

", e);

}writelog(str);

messagebox.show(

"", "

系統錯誤

", messageboxbuttons.ok, messageboxicon.error);

}static

void currentdomain_unhandledexception(object

sender, unhandledexceptioneventargs e)

else

writelog(str);

messagebox.show(

"", "

系統錯誤

", messageboxbuttons.ok, messageboxicon.error);

}//////

寫檔案

/// ///

static

void writelog(string

str)

using (streamwriter sw = new streamwriter(@"

errlog\errlog.txt

", true

)) }}

}

C winform 捕獲全域性異常

using system using system.collections.generic using system.windows.forms using system.io namespace gobalexception catch exception ex r n異常訊息 r n異常資訊 r...

C WINFORM 捕獲全域性異常

using system using system.collections.generic using system.windows.forms using system.io namespace gobalexception r n異常訊息 r n異常資訊 r n ex.gettype name,...

C winform 捕獲全域性異常

using system using system.collections.generic using system.windows.forms using system.io namespace gobalexception r n異常訊息 r n異常資訊 r n ex.gettype name,...