Is it guaranteed that your code will reach the finally
? Yes (barring some cataclysmic event such as the world coming to an end... or, you know, your computer losing power or your OS crashing).
But it's important to recognize that, if it's absolutely critical that your code runs, you better make sure your code doesn't throw an exception itself!
Take this for example:
IDisposable someDisposableObject = null;
IDisposable someOtherDisposableObject = null;
try
{
someDisposableObject = GetDisposableObject();
throw new Exception("Holy crap, something bad happened.");
someOtherDisposableObject = GetOtherDisposableObject();
}
finally
{
// This will throw a NullReferenceException...
someOtherDisposableObject.Dispose();
// ...so this actually won't run.
someDisposableObject.Dispose();
}
So if you want your entire finally
block to be run, it's important to write it properly so that an exception is (ideally) impossible.