I’ve got an ASP.NET project with some custom controls, which subclass some standard controls. Eg. MessageLabel subclasses Label, and adds some additional formatting and css properties.
Compiled controls are in same web project, in the MyProject.Controls namespace, and referenced into the project through web.config by adding the following under system.web -> pages -> controls.
<add tagPrefix=”myproj” namespace=”MyProject.Controls” assembly=”MyProject” />
On ASPX pages, controls are added using the following syntax:
<myproj:MessageLabel ID=”MessageLabel1″ runat=”Server” />
Except, this breaks the designer file! As soon as the control is added to the page, adding any additional controls or saving the page will show the following error in the errors list:
Generation of designer file failed: Unknown server tag ‘myproj:MessageLabel’
This is a big annoyance, as it means that this and any other controls added to the page will not be updated in the [no-longer] generated designer file, stopping them from being accessed in the code-behind.
The only workaround I’ve found is to manually add the register directive at the top of each ASPX page:
<%@ Register Assembly=”MyProject” Namespace=”MyProject.Controls” TagPrefix=”myproj” %>
…which completely defeats the purpose of adding the assembly reference in web.config. Some other people experiencing this problem a while back reported that it was fixed in VS2005 SP1, but I’m using SP1 and in my experience it doesn’t seem this is the case.
Very, very annoying.
[...] Adding in the MasterPageFile setting into the page seems to get rid of the problem. Reminds me of the problems I had earlier with controls. I’m going to avoid using web.config for these kinds of things where possible as it seems to cause more problems than it solves! Other posts that might be related to this: [...]
Pingback by mUnit : Mun talks technology » Unrecognized tag prefix or device filter ‘asp’ — June 11, 2007 @ 10:13 am
I ran into the same problem but adding the Register directive did nothing for me. What I ended up doing was commenting out the offending control and then converted just that page into a web application project. That seemed to get rid of the error and I just uncommented the offending control.
Comment by David — September 26, 2007 @ 10:40 pm