Consider we have this snippet of code:
static void Main(string[] args)
{
try
{
throw new Exception("Exception");
}
catch
{
throw;
}
finally
{
Console.WriteLine("------finally-----");
}
}
We have unhandled exception and finally
block.
When werfault
is enabled and I press Cancel
when it is trying to "automatically solve problem" finally block executes.
But if I'm not pressing Cancel
and in the next window clicking Close The Program
finally block doesn't execute.
And finally when I disable werfault
and click Close Program
finally block executes.
I didn't find any documentation in c# spec that describes this situation. Also I found this on MSDN
:
Execution of the finally block after an unhandled error depends on how the exception unwind operation is triggered.
But there is no explanation, anyone can describe why this is happening ?
Update 1: I have tested it in .Net Framework 4.5.1 and 4.5.2.