Cry about...
MS-Windows Troubleshooting

Server Error in Application ... The base class includes the field 'ABC', but its type (Components_ABC) is not compatible with the type of control


After deploying a working ASP.NET application to a server, when trying to render a page the following error is generated:

Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The base class includes the field 'ABC', but its type (Components_ABCControl) is not compatible with the type of control (ASP.components_abccontrol_ascx).

The same information will also be recorded in the Application event log.

Where "ABC" in the above is the ID assigned to the control on the page, and the (web user) control itself is called "ABCControl" and in my case was in a separate folder called "Components". Needless to say your names will be different.


This error seems to be caused by a circular reference in the code, specifically there is a circular reference between the two components.

In my case the form didn't use the named web control directly but used another web control - which I'll call "XYZ". So my "XYZ" web control used the "ABC" web control, but the "ABC" web control didn't use any other web controls. So at first glance a circular dependency seemed unlikely, but it was there or at least the compiler thought so. The problem turned out to be how the compiler deals with folders.

My folder arrangement was:



To the compiler seems to consider a directory as being dependent on any sub-directories that it contains. So to the compiler any web component in the folder ~/Components has a dependency on anything in ~/Components/Section (and any other sub-directories). So it was my folder naming that gave me a circular dependency, not what the files in turn used.

Annoyingly this all worked fine on the development machine.

Possible Remedies

This issue is dealt with in the Microsoft knowledge base article 919284.

Firstly identify where the circular dependency comes from (see "Cause" above). Remember that this may be in the naming and order of any folders, and not directly a function of the code.

  • Reorder the folders to avoid the dependencies the compiler introduces. A simple approach would be to put all web controls in the same folder, an alternative would be to understand the dependency issue and adopt a logical folder hierarchy which avoides the problem. The simple rule to remember is that no web-control should use another which is in a parent folder (but child of a parent folder is fine). This is the preferred approach.
  • In some cases (but not all), modifying the web.config file and setting batch property of the <compilation> element to false will avoid the error because each file is then compiled into a separate assembly. In my case this didn't resolve the problem, but I have seen it work. The disadvantage of this is that it can lead to additional memory fragementation because it may cause a project to generate a lot of assemblies.

These notes have been tested within Microsoft Visual Studio .NET 2010 targetting the .NET 4 framework, running under Windows 8 and Windows 2008, and may apply to other versions as well.

About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.