I've encountered this weird issue of silent exceptions in 64 bit. What is that cause this bahavior? I would like to understand why does this occur and what is the recommended solution?
on the main:
try
{
Application.Run(new Form1());
}
catch
(Exception ex)
{
MessageBox.Show("Error");
}
private void Form1_Load(object sender, EventArgs e)
{
throw new Exception("oh no!");
}
You can also define "silent" exceptions that do not, by default, cause the application to show the error message. Silent exceptions are useful when you don't intend to report an exception to the user, but you want to abort an operation.
An event that occurs during the execution of a program that disrupts the normal flow of instructions is called an exception. Example: public static void Main ()
In Java terminology, creating an exception object and handing it to the runtime system is called throwing an exception. After a method throws an exception, the runtime system leaps into action to try and find someone to handle the exception.
Exception Texts. Each exception is assigned a text that can be given parameters using attributes and that describes the exception situation. This text is displayed in the short dump of the runtime error if the exception is not handled.
In order to load a form, your code will call into a kernel function to create the form's window, and this kernel function will in turn call back into your code by sending a message that invokes your OnLoad
method. If you throw an exception in that method, the exception handling mechanism walks the call stack back to the kernel mode boundary.
On x86 an exception can go through this boundary and back to the original caller. On x64 it stops when it hits the boundary and cannot continue. In XP64 and Vista the exception was swallowed (ignored), while a 64-bit app with a manifest saying it is Win7-compatible will crash when this happens. To get the crashing behavior on other OSes or for 32-bit apps on 64-bit Win7, see KB976038.
This behavior will happen for any event handler that is invoked as a callback from kernel mode on x64.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With