July 21, 2006

Control Designer Gotcha

This week I've been programming a custom web server control. It required some specific behavior while being manipulated in the design view of Visual Studio 2005. To achieve this I decided to extend a ContainerControlDesigner to suit my needs. In order to test my new control as I worked on it, I added my efforts to a web project.

However, despite importing the ContainerControlDesigner's namespace (System.Web.UI.Design), the class definition could not be found and as a result it wouldn't compile. I discovered that the classes in the System.Web.UI.Design namespace belong to the System.Design.dll assembly which is not referenced by default in a Visual Studio 2005 web project. I had mistakenly assumed this class was already a part of the referenced System.Web.dll. After adding a reference to System.Design.dll (see image below) my custom control designer compiled flawlessly.

1 comment:

Anonymous said...

I just encountered this same issue on the Windows Forms side. Surely a class in the System.Windows.Forms.Design namespace should be in the System.Windows.Forms assembly?

Clearly not according to Microsoft!!