Try-Catch-Finally block problems with .NET4.5.1

前端 未结 3 2078
滥情空心
滥情空心 2020-12-31 04:28

I have a simple try-catch-finally code block that works as expected in .NET3.5, but the same code behaves completely different on a project created with .NET4.5.1. Basically

3条回答
  •  悲哀的现实
    2020-12-31 04:51

    On top of what Lipper wrote, note that it is written in MSDN... Under the try...finally:

    However, if the exception is unhandled, execution of the finally block is dependent on how the exception unwind operation is triggered. That, in turn, is dependent on how your computer is set up.

    and

    Usually, when an unhandled exception ends an application, whether or not the finally block is run is not important.

    and then it goes on to explain that if you put a try... catch at a "high" level then the inner try... finally will be executed.

提交回复
热议问题