How many times has this happened to you? You make a few changes to your codebase, hit Ctrl+F5 to run your app and, after about five long minutes of building, you are greeted not with your app but with a basic Windows Form containing only one of your custom controls. What happened? Most likely one your fellow developers, frustrated with having to run the entire app to just to test a single control, created this empty form simply to hold the control in question and altered the Program.cs file to run this form instead of your main shell.
And then, they checked it in.
If you've never encountered this consider yourself lucky. It's actually a pretty common practice that often results in this pretty common mistake. But that's not the worst of it, the worst part is that it's often completely unnecessary.
You see, Visual Studio ships with a “User Control Test Container” which is pretty much just a fancy panel and property grid that will let you host and run your controls which out creating a special form for them.
Here’s yow you do it…
- Open up the “Properties” page of the of the project which holds your custom controls. For arguments sake let's call it MyCustomControls.
- Click the Debug tab.
- Choose “Start external program:” and then browse to the User Control Test Container found in <Program Files>/Microsoft Visual Studio 8/Common7/IDE/UserControlTestContainer.exe
- Under “Start Options”->”Command line arguments:” enter “MyCustomControls.dll”, or the name of the assembly generated by your controls project. Note that you don’t have to specify a full path here, the path will automatically default to the current working directory of the current AppDomain.

- Save and close the properties.
- Now, right click on the MyCustomControls project in the Solution Explorer and choose “Set as startup project..”. The project will now become bold.

- Finally, click “Debug->Start Debugging” in the main menu
- In the resulting form, simply choose the control that you want from the drop down box and it will be displayed in the panel. You can interact with it as normal and also view top level attributes of the control itself. Note that the list of controls in the drop down box is not sorted so you may have to search a bit to find the one that you want.

Remember that you can load other control assemblies by using the “Load” button. Also, keep in mind that since the test container was launched in the same process as Visual Studio that you can step into your code, set breakpoints, stop on exceptions, etc just like you could before. Only you don’t need a new form to do this, and perhaps most importantly, you don’t have to check out the project, add the form, alter the Program.cs file, and then remember to undo all of this before you check everything back in.
You'll actually get this functionality for free (
without performing the setup steps mentioned before) if you create your controls project as a "Windows Control Library" instead of a "Class Library". Also, remember that this unfortunately only works for Windows Forms controls, not web controls as you may expect.