using system;
using system.collections.generic;
using system.windows.forms;
using system.io;
namespace gobalexception
catch (exception ex)
\r\n異常訊息:\r\n異常資訊:\r\n",
ex.gettype().name, ex.message, ex.stacktrace);
}else
", ex);
}writelog(str);}}
///做法很多,可以是把出錯詳細資訊記錄到文字、資料庫,傳送出錯郵件到作者信箱或出錯後重新初始化等等
///這就是仁者見仁智者見智,大家自己做了。
///
///
///
\r\n異常訊息:\r\n異常資訊:\r\n",
error.gettype().name, error.message, error.stacktrace);
}else
", e);
}writelog(str);
}static void currentdomain_unhandledexception(object sender, unhandledexceptioneventargs e)
else
writelog(str);
}///
/// 寫檔案
///
///
static void writelog(string str)
using (streamwriter sw = new streamwriter(@"errlog\errlog.txt", true))}}
}**:
還找到乙個例子:
你好!// creates a class to throw the error.
public class errorhandler : system.windows.forms.form
public static void main(string args)
}// creates a class to handle the exception event.
internal class customexceptionhandler
catch
finally
}// exits the program when the user clicks abort.
if (result == dialogresult.abort)
}// creates the error message and displays it.
private dialogresult showthreadexceptiondialog(exception e)
}
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,...