This article is to guide you in Debugging C# Windows Forms Usercontrols at Design Time.
If you are creating a user control you may be required to debug the user control during design time to ensure the user control will function as expected while in use.
This article explains the steps in detail to help you debug user control in design mode.
Table of Contents
Debug C# Winforms User controls at Design Time
To debug C# Winforms User controls at Design Time, follow steps mentioned below
1. Create your user control library and build it. See the article Create Windows Forms User control to understand how to create a user control in C# windows application.
2. Create the project wherein you want to use the User control Library as explained in the Testing user control section of the article Create Winforms User control
3. From the visual studio toolbox, drag and drop the desired user control into the desired form.
4. Right-click on the Usercontrol Library project and set it as startup project
5. Go to Properties window of the user control library project and Click the Debug tab and in Start Action section choose Start external program and set it as devenv.exe(Browser the external program path as C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe).
6. Place the debug breakpoint in the desired location of the usercontrol’s source code.
7. Run the solution.User control will now run as a separate instance and it will open another instance of Visual Studio.
8. Keep the instance of UserControl Libray running and open the same solution again in the new opened visual studio instance.
9. Now you can see the breakpoint hit in design mode.You can start debugging as normal debugging.
10. Open the form wherein you placed the user control.Change the properties of the user control from properties window (the defined properties of the user control will be available in properties window) and see the breakpoint hits in design mode when you change a property and hit the Enter key.
Summary
Hope we were able to guide you in debugging C# WinForms user controls at design time or Now it is your turn, provide us your valuable feedback about C# user controls and debugging C# WinForms user controls in the comment section below.
Happy debugging!
Related terms of this post:
How to debug designer in visual studio,
Debug designer visual studio 2013,
How to debug user control c#,
Debug custom control,
Rectify design time errors in the windows forms designer
Free .NET PDF Libraries & Components
Leave a Reply