您的位置:首页 >> Web开发 >> ASP.NET >> ASP.Net教程 >> 正文
ASP.Net教程 RSS
 

asp.net自定义异常处理

http://www.rdxx.com 08年09月29日 13:30 我要投稿

关键词: 异常处理 , ASP.NET , .NET , ASP , 异常
 
  //自定义异常处理类
  using System;
  using System.Diagnostics;
  namespace MyAppException
  {
  /// <summary>
  /// 从系统异常类ApplicationException继承的应用程序异常处理类。
  /// 自动将异常内容记录到Windows NT/2000的应用程序日志
  /// </summary>
  public class AppException:System.ApplicationException
  {
  public AppException()
  {
  if (ApplicationConfiguration.EventLogEnabled)LogEvent("出现一个未知错误。
  ");
  }
  public AppException(string message)
  {
  LogEvent(message);
  }
  public AppException(string message,Exception innerException)
  {
  LogEvent(message);
  if (innerException != null)
  {
  LogEvent(innerException.Message);
  }
  }
  //日志记录类
  using System;
  using System.Configuration;
  using System.Diagnostics;
  using System.IO;
  using System.Text;
  using System.Threading;
  namespace MyEventLog
  {
  /// <summary>
  /// 事件日志记录类,提供事件日志记录支持
  /// <remarks>
  /// 定义了4个日志记录方法 (error, warning, info, trace)
  /// </remarks>
  /// </summary>
  public class ApplicationLog
  {
  /// <summary>
  /// 将错误信息记录到Win2000/NT事件日志中
  /// <param name="message">需要记录的文本信息</param>
  /// </summary>
  public static void WriteError(String message)
  {
  WriteLog(TraceLevel.Error, message);
  }
  /// <summary>
  /// 将警告信息记录到Win2000/NT事件日志中
  /// <param name="message">需要记录的文本信息</param>
  /// </summary>
  public static void WriteWarning(String message)
  {
  WriteLog(TraceLevel.Warning, message);
  }
  /// <summary>
  /// 将提示信息记录到Win2000/NT事件日志中

 
 
标签: 异常处理 , ASP.NET , .NET , ASP , 异常 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站