Friday, January 9, 2009

Visual Studio and Auto Toolbox Populate

When I began working for my current employer, I joined the largest .NET software project that I have worked with to date. One of our standards is that virtually every UI element is contained within it's own user control. This makes for great re-usability however, it causes increased build times because each build caused the controls within Visual Studio's toolbox to be refreshed. I was told that there was no way around this, and I just assumed that this was correct. However, recently during what felt like a rediculously long wait for a build to complete, I decided to research the issue. Wouldn't you know it, I stumbled across an old post from ScottGu that mentioned an AutoToolboxPopulate setting (along with lots of other useful information). Setting "Tools --> Options --> Windows Forms Designer --> AutoToolboxPopulate" to False prevents the Toolbox from being populated with each build, and has dramatically improved my build times.

The only drawback to setting this to False, is now your user controls will not automatically appear in the Toolbox. At first, I found myself enabling/disabling the setting depending on if I needed to work with UI elemenets, or not. But, then I discovered a function under the Project menu, "Refresh Project Toolbox Items". This allows you refresh Toolbox on demand, instead of with every build. Problem solved.

2 comments:

Antonio J. Zozaya said...

"The only drawback to setting this to False, is now your user controls will not automatically appear in the Toolbox."

Yeah, I know this is old (2009) but, You saved mi life. I'm starting to work with user controls, and I had this problem. Of course I prefer to set AutoToolBoxPopulate to False by default.

Thank you so much.

Robson Previato said...

Great!