I\'m not sure if this is the right place to ask but I shall anyway.
I have 2 .NET applications; one that was compiled by myself, the other not. Both use .NET Framewo
The solution presented by Hans Passant will terminate the application. This also means that remaining finally
blocks are not executed any more.
You can also use PInvoke to change the behavior by calling the SetErrorMode() method.
public enum ErrorModes : uint
{
SYSTEM_DEFAULT = 0x0,
SEM_FAILCRITICALERRORS = 0x0001,
SEM_NOALIGNMENTFAULTEXCEPT = 0x0004,
SEM_NOGPFAULTERRORBOX = 0x0002,
SEM_NOOPENFILEERRORBOX = 0x8000,
SEM_NONE = SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX
}
[DllImport("kernel32.dll")]
static extern ErrorModes SetErrorMode(ErrorModes uMode);
and then call
SetErrorMode(ErrorModes.SEM_NONE);
Doing so will give the finally
blocks the chance to run.