我正在开发一个测试程序,帮助我弄清楚如何使用Microsoft.Practices.EnterpriseLibrary.ExceptionHandling框架.该程序定义了几种自定义异常类型,并将自定义异常处理程序与每种类型相关 在运行时,程序会提示用户输入异常类型,抛出异常,并使用ExceptionHandling框架为异常类型调用适当的异常处理程序:
using System;
using System.Collections.Specialized;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;
namespace ConsoleApplication1
{
public class AException : Exception { public AException(string message) : base(message) { } }
public class BException : Exception { public BException(string message) : base(message) { } }
public class BBException : BException { public BBException(string message) : base(message) { } }
public class WrapperException : Exception
{
public WrapperException(Exception innerException)
: base("Wrapped exception: [" + innerException.Message + "]", innerException) { }
}
public class …Run Code Online (Sandbox Code Playgroud)