Generation of Designer File Failed: Unknown Server Tag

I was doing some experimentation with custom web server controls in ASP.NET 2.0 so I created a quick Web Application Project and started throwing some controls in, using them on the page that gets put in the app by default.  Unfortunately, I started getting the following warning:

Generation of designer file failed: Unknown server tag 'cc1:MyServerControlName'.

For a minute, I thought maybe I had forgotten the <%@ Register %> directive at the top of the page, but, no, there it was:

<%@ Register Assembly="MyTestAssembly" Namespace="MyTestNamespace" TagPrefix="cc1" %>

I struggled for this with some time, building and rebuilding, searching and not really finding much on the web at large, and then I tried something that worked:

If the page and the custom control are in the same assembly, remove the "Assembly" portion of the directive.  For some reason, the designer just doesn't understand it if you specify the assembly you're tasked to build.  I'm not sure why.  So the directive becomes:

<%@ Register Namespace="MyTestNamespace" TagPrefix="cc1" %>

Once I did that, everything worked great.  YMMV.

UPDATE: If you're using master pages and the control in question is inside a Content control, you may still see weirdness about unrecognized server tags.  In that case, add the tag prefix registration to web.config, again omitting the assembly:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <pages>
      <controls>
        <add tagPrefix="cc1" namespace="MyTestNamespace"/>
      </controls>
    </pages>
  </system.web>
</configuration>

One thing I noticed was that this seems to be... maybe a little flakey.  Depending on the circumstances, you may get a page that says your control tag is unrecognized at runtime.  That will require you add the "assembly" bit to the tag prefix registration in web.config... but that will cause you to have trouble in design time because the designer file won't be generated properly.  Erg.

Print | posted @ Thursday, August 02, 2007 10:37 AM

Comments on this entry:

Gravatar # re: Generation of Designer File Failed: Unknown Server Tag
by Angus at 8/26/2007 9:14 PM

Thanks very much! I'd been struggling with this intermittently for a while.

My control was on a master page, but removing the Assembly attribute from the Register was enough to make it work... Thanks again!
Gravatar # re: Generation of Designer File Failed: Unknown Server Tag
by Gc at 8/29/2007 9:20 AM

Thanks a bunch man. I am creating a webportal, and was trying to overwrite a webzone. After I created the custom webzone, studio would not let me register it with the web page. The book I am reading by Neimke on web parts doesn't mention a word of this. Anyway, I did what you said, register it on the page without the assembly directive, and register it in the web.config file with it, and it worked perfect.
Gravatar # re: Generation of Designer File Failed: Unknown Server Tag
by srini at 10/17/2007 12:52 PM

Is there a resolution to the issue when the page and controls are in two different assemblies.
Gravatar # re: Generation of Designer File Failed: Unknown Server Tag
by Martino at 11/15/2007 10:29 AM

I had the same problem. My control was in a different assembly then the page. After 2 hours of trying all kinds of stuff i finaly decided to restart my IDE and the aspnet_wp.exe process. After this the warning wasn't there anymore and my designer file even created a reference to the control.
Gravatar # re: Generation of Designer File Failed: Unknown Server Tag
by Tofino at 5/9/2008 11:08 AM

Thanks -- just ran into this annoying issue and it took two minutes to solve thanks to you!

Your comment:

Title:
Name:
Email:
Website:
 
Italic Underline Blockquote Hyperlink
 
 
Please add 5 and 2 and type the answer here: