Posts

Showing posts with the label user-controls

c# UserControl constructor don't throws exceptions as expected

c# UserControl constructor don't throws exceptions as expected This is my WinForm solution entry point in Program.cs: try { Application.Run(new MainForm()); } catch (Exception e) { Log.error(e.ToString()); ErrorHandlerForm abend = new ErrorHandlerForm(e); abend.ShowDialog(); } It works fine, every exception thrown in my solution is gracefully handled! But today I found an issue: My program don't catch exceptions that occurs in UserControls construstors! It simply crash to windows with the ugly system prompt (or it shows the error in the VisualStudio if i am in debug mode). I don't understand this behaviour and I have no idea how to fix it, I want to catch those exception in my catch block. what error do you get in Visual studio when in debug mode ? – Prany Jul 1 at 17:13 ...