我想在下面的代码的空catch块中测试一些异常处理逻辑。如何抛出一个不会从Exception继承的异常?
try
{
//Do Some stuff that throws a exception
//This is the code i need
}
catch (Exception)
{
//Handle things that inherits from Exception
}
catch
{
//Handle things that dont inherits from Exception
//Want to test this code
}
一个非常重要的一点是,'犯规继承Exception'是可能的,但只有在CLR1.0平台,或与[WrapNonExceptionThrows](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.runtimecompatibilityattribute.wrapnonexceptionthrows.aspx)关闭 - 这两个都很少见。 – quetzalcoatl 2013-06-14 13:20:10