18. September 2012 13:51
If you are creating a user control it may required to debug the user control during design time to ensure the user control is functioning as expected while in use.This article explains the steps in detail to help you debug your user control in design mode.Follow the steps 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 where you want to use the User control Library as explained in the Testing user control section of the article Create Windows Forms User control
3.Drag and drop the desired user control from the visual studio toolbox in to the desired form.
4. Right click on the UsercontrolLibrary project and set as start up project
5. Go to Properties of the UsercontrolLibrary project and Click the Debug tab and in Start Action section choose Start external program and set it as devenv.exe(Browser the path as C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe).
6. Place the break point in the user control source code's desired location.
7. Do run the solution.Usercontrol will now run as a separate instance and it will open another instance of Visual Studio.
8. Keep the instance of UserControlLibray running and open the same solution again in the new opened visual studio instance.
9. Now you can see the break point hit in design mode.You can start debugging as normal debugging.
10.Open the form where in you placed the user control.Change the properties of the user control from properties window (the defined properties will be available in properties window) and see the break point hits in design mode when you change property and hit Enter.