Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging the InitializeComponent function in the Visual Studio designer

In testing a number of changes to a custom WinForms control I'm encountering some issues which only occur when loading a form hosting the custom control in the Visual Studio designer.

As a result, I'd like to understand if there is any method for debugging and stepping through (or logging in some way) the behaviour of the custom control's code when the Visual Studio designer loads.

like image 864
Chris Cook Avatar asked Jul 15 '26 14:07

Chris Cook


2 Answers

When debugging custom controls, you need to launch a second instance of Visual Studio by setting your project's debug properties to "start external program" and set the executable path to devenv.exe.

Then in the second instance of VS, open the project you're working on, and you will be able to debug the code triggered by the designer. In the 1st instance, set breakpoints in your custom control, and they will be hit when the 2nd instance calls up the Form.

Cheers

like image 137
Luc Morin Avatar answered Jul 17 '26 16:07

Luc Morin


VS2015: Under "Debug", "Options", "Debugging", "General" uncheck the "Enable just my Code".

like image 26
Horst Schmid Avatar answered Jul 17 '26 15:07

Horst Schmid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!