Why is the Form_Load event already catching all Exceptions?

Ive placed my initialization code when loading the form, since you should not leave it in the constructor, because the designer may work.

The problem is that Ive just realized that any exception inside the form load event will break locally !

Why? How can I overcome this?

private void Form1_Load(object sender, EventArgs e) { //This exception will be catch internally (I don't know why and where) throw new Exception("test"); } 
+4
source share
1 answer

This is a mistake and is explained here:

OnLoad exception case disappears - user mode callback exceptions in x64

http://blog.paulbetts.org/index.php/2010/07/20/the-case-of-the-disappearing-onload-exception-user-mode-callback-exceptions-in-x64/

VS team response: From here: https://connect.microsoft.com/VisualStudio/feedback/details/357311/silent-exceptions-on-x64-development-machines

Submitted by Microsoft @ 22/04/2010 17:12 Hello

This error was closed as "External" because this behavior is explained by the way the x64 version of Windows handles exceptions. When a user-mode exception crosses the kernel transition, x64 versions of Windows do not allow the exception to propagate. Therefore, attached debuggers are not aware that an exception has occurred, as a result of which the debugger could not break the unhandled exception.

Unfortunately, nothing that the Visual Studio team can do to solve this problem is the result of developing an operating system. All feedback on this should be addressed to the Windows team; however, the Windows team believes that this is the β€œcorrect” design of the operating system, and considers the x86 behavior to be β€œwrong.”

Best regards, Visual Studio Debugger


Solution using Im: Ive placed the code that was inside the form loading constructor, and I check if the application works in the designer or not

  protected static bool IsInDesigner { get { return (Assembly.GetEntryAssembly() == null); } } if (!MainForm.IsInDesigner) LoadControl(); 
+2
source

All Articles