【发布时间】:2013-05-15 23:33:54
【问题描述】:
为什么从 System.Exception 继承的类在 try catch 块中不起作用?
以下截图不会触发 catch 块
try
{
int a = 3;
int b = 0;
int c = a/b;
}
catch (CustomEx er)
{
Console.Write(er.Message);
}
public class CustomEx:Exception
{
}
【问题讨论】:
-
“不起作用”是什么意思?它不编译? var ex = (CustomEx)Server.GetLastError();应该编译。但我不会尝试显式转换,因为可能有很多错误原因。你到底想达到什么目的?
-
我已经改变了一点问题,因为问题在于每个错误不仅仅是 getlasterror
标签: asp.net exception-handling global-asax