Generation of designer file failed

The error message “Generation of designer file failed: Unknown server tag ‘EPiServer:Property’” in Visual Studio can really drive me mad.

Today it happened again. I noticed that I could not recompile my application because the new textbox I added to my ASPX-file did not appear as a member in the corsponding designer.cs-file.

First, I double check that I installed SP1 for Visual Studio 2005 so I have the latest version of Web Application Projects.

The Usual Trick

When this happens it is in most cases an indication of a syntax error in the ASPX-file. In many cases you get so many strange errors and warnings in Visual Studio’s Error List so you do not understand what is wrong. A quick way to get a good error message and be certain that the designer.cs-file is in sync is to first delete it and then regenerating it by right-clicking the ASPX-file in the Solution Explorer and selecting “Convert to Web Application”.

This works in most cases. Either you will get an error you will understand how to fix or it just regenerates the designer.cs-file for you.

Permanent Frustration

Sometimes you will fail to generate the file and nothing you do seem to help. Everything is in order. No syntax errors in the ASPX-file. It just refuses to regenerate the designer file because it cannot find component X.

Obviously I’m not alone getting this problem. I’m not sure why it stops working but I guess part of the problem is related to the ASPX-file must be parsed first and something is wrong with the environment.

Tim McBride on the ASP.NET team hints how to get more information by turning on debugging for Web Application Projects.

REGEDIT4
[HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio8.0WebApplicationProjectsDebug]
"LogFile"="C:logfile.txt"
"Enabled"=dword:00000001"
LogFieldGeneratorFailures"=dword:00000001

And with a call stack we have more information where it goes wrong:

System.Web.HttpParseException: Unknown server tag 'EPiServer:Property'.
   at System.Web.UI.TemplateParser.ProcessError(String message)
   at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
   --- End of inner exception stack trace ---
   at System.Web.UI.TemplateParser.ProcessException(Exception ex)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
   --- End of inner exception stack trace ---
   at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ParseInternal()
   at System.Web.UI.TemplateParser.Parse()
   at System.Web.UI.DesignTimeTemplateParser.ParseTemplate(DesignTimeParseData data)
   at Microsoft.VisualStudio.Web.Application.Parser.Parse()
   at Microsoft.VisualStudio.Web.Application.Generator.UpdateDesignerClass(String document, String codeBehind, String codeBehindFile, String[] publicFields, UDC_Flags flags)

ProcessBeginTag cannot map a tag to a control. The tag EPiServer:Property control is not registered on the page but in the <system.web><pages><controls> section in web.config. This indicates that something fails either in TemplateParse.PrepareParse when trying to get hold of the RuntimeConfig or in Microsoft.VisualStudio.Web.Application.Parser.ParseConfig when it tries to get to web.config through the designer host.

Adding a Register directive manually to the Page will remove the first error and reveal another.

System.Web.HttpParseException: The expression prefix 'Resources' was not recognized.  Please correct the prefix or register the prefix in the <expressionBuilders> section of configuration.
   at System.Web.Compilation.ExpressionBuilder.GetExpressionBuilder(String expressionPrefix, VirtualPath virtualPath, IDesignerHost host)
   at System.Web.UI.ControlBuilder.AddBoundProperty(String filter, String name, String expressionPrefix, String expression, ExpressionBuilder expressionBuilder, Object parsedExpressionData, Boolean generated, String fieldName, String formatString, Boolean twoWayBound)
   at System.Web.UI.ControlBuilder.PreprocessAttribute(String filter, String attribname, String attribvalue, Boolean mainDirectiveMode)
   at System.Web.UI.ControlBuilder.PreprocessAttributes(ParsedAttributeCollection attribs)
   at System.Web.UI.ControlBuilder.Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs)
   at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type& childType, Boolean defaultProperty)
   at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)

The code in GetExpressionBuilder gives the same indication and strengthens my suspicion that the parser fails to get hold of any configuration at all since the <expressionBuilders> tag is in the global web.config.

I’m too tired to continue the hunt for the real reason tonight but I did test one final thing:

  1. I shut down the IIS service and close Visual Studio.
  2. And then do I delete all files under “Temporary ASP.NET Files”.
  3. I restart Visual Studio and re-open the Project.
  4. I change Project Settings to use Visual Studio Development Server instead of IIS.
  5. Finally do I click “Convert to Web Application” and this time it generates without errors…

Why? Maybe you know… Please, leave a comment if you have any clues!

Bookmark and Share

Tags: , ,

  1. Amit soni’s avatar

    I am working with VS2005. My web application is IIS (localhost) application. Not able to see any designer.cs file in project for any of the .aspx page. Code is sent to client and he complaining about not creation of .designer.cs file.

    What is the problem?
    -Amit

    Reply

  2. Fredrik’s avatar

    Amit, there are two diffrent types web project models in VS2005. You have Web Site Project and Web Application Project. The later is similar to the model used in VS2003 and you precompile you code-behind classes to an assembly before you deploy it.

    The designer.cs file is needed to be able to precompile and does only exist in Web Application Projects.

    I’m not sure what your client is complaining about but you should consider migrate your Web Site Project and Web Application Project.

    Note! You do not have to download or install anything anymore because it is integrated in VS2005 SP1.

    /Fredrik

    Reply

  3. Fredrik Heidgert’s avatar

    We had the exact same problem and the solution was to add the following line in the master-page:

    For EPiServer CMS 5:

    For EPiServer 4:

    Perhaps not related to your specific problem but the syndrome seems to be the same.

    Reply

  4. Fredrik Heidgert’s avatar

    Oops, the strings were stripped, here we go again:

    For EPiServer CMS 5:
    <%@ Register TagPrefix=”EPiServer” Namespace=”EPiServer.Web.WebControls” Assembly=”EPiServer.Web.WebControls” %>

    For EPiServer 4:
    <%@ Register TagPrefix=”EPiServer” Namespace=”EPiServer.WebControls” Assembly=”EPiServer” %>

    Reply

  5. Fredrik Haglund’s avatar

    Hi Fredrik!

    The register tag should not really be needed since the web controls in these namspaces are imported by the pages-tag in web.config.

    I can understand if it helps in some cases though, since this is a problem where the visual studio environemnt either fails to load assemblies or fails to get hold of anything in web.config.

    /Fredrik

    Reply

  6. Bharath’s avatar

    Fredrik, I have the exact problem that you do. My code was working in VWD 2005 express edition and now the same code won’t compile in VS.NET 2008 framework 3.5. I’ve all my controls registered in web.config. Were you able to resolve this issue? Please post. Thank you.

    Reply

  7. Fredrik Haglund’s avatar

    Yes, Bharath, I did get it to work but my problem was not related to VWD 2005 or upgrading to VS.NET 2008.

    I think you could benefit from reading this post to read more about how to get control of you assembly dependencis because that could be an issue when you upgrade that probably can provoke the error above.

    Reply