【发布时间】:2015-05-19 05:22:18
【问题描述】:
我有一个 C# (.net 4.0) 程序,其主要是从外部 FTP 库调用方法 - 项目引用的 dll。逻辑在 try-catch 块中,catch 打印错误。异常处理程序有一个通用参数:catch(Exception ex)。 IDE 是 VS。
有时 FTP 库会引发以下除以零异常。问题是它没有被 catch 块捕获,程序崩溃了。 源自我的包装代码的异常被捕获。任何人都知道有什么区别以及如何捕获异常?
例外:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DivideByZeroException
Stack:
at ComponentPro.IO.FileSystem+c_OU.c_F2B()
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
【问题讨论】:
-
看起来异常发生在不同的线程中。尝试处理
AppDomain.UnhandledException
标签: c# .net exception dll exception-handling