Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Error messages when you try to run an ASP.NET 2.0 Web application that is built on the .NET Framework 2.0


View products that this article applies to.

Symptoms

When you try to run a Microsoft ASP.NET 2.0 Web application that is built on the Microsoft .NET Framework 2.0, you may receive an error message that resembles one of the following error messages:
The base class includes the field 'MyControl_1', but its type (MyControl) is not compatible with the type of control (ASP.MyControl_ascx).
Unable to cast object of type 'ASP.MyControl_ascx' to type 'MyNameSpace.MyControl '.
Circular file references are not allowed.
Note In these error messages, MyControl is the name of the control that has caused the error. MyNameSpace is the name of the namespace that this control is a member of

↑ Back to the top


Cause

This is problem occurs because of the way in which ASP.NET 2.0 uses the application references and the folder structure of the application to compile the application. If the batch property of the <compilation> element in the web.config file for the application is set to true, ASP.NET 2.0 compiles each folder in the application into a separate assembly. In this scenario, a circular reference may occur. Additionally, the compilation process may fail if either of the following conditions is true:
  • The application contains references to Web controls.
  • The application contains references to Web pages that are outside the current directory.

↑ Back to the top


Resolution

To resolve this problem, use one of the following methods:

Method 1: Modify the web.config file

To modify the web.config file, set the batch property of the <compilation> element in the web.config file for the application to false.

Note This method is recommended only for small applications. In large production applications, when you set the batch property to false, ASP.NET 2.0 compiles each page in the application into a separate assembly. The individual page assemblies are then loaded at the next available memory location. Additionally, the individual page assemblies cannot be moved. This causes memory fragmentation.

Method 2: Reorder the folders in the application

To avoid a circular reference, reorder the folders in the application. To reorder these folders, follow these steps:
  1. Trace the references to the file and from the file that is indicated by the error message.
  2. Identify the circular reference.
  3. To avoid the circular reference, put the referenced files together in the same folder.

↑ Back to the top


More information

For more information about how to use the <compilation> element in the web.config file, visit the following Microsoft Developer Network (MSDN) Web site: http://msdn2.microsoft.com/en-us/library/s10awwz0.aspx

For more information about another error that can cause an InvalidCastException to be thrown in an ASP.NET-connected Web application, click the following article number to view the article in the Microsoft Knowledge Base:
915782 FIX: You may receive an InvalidCastException error in an ASP.NET-connected Web application

↑ Back to the top


Properties

Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

↑ Back to the top


Keywords: KB919284, kbprb, kbtshoot, kbasp

↑ Back to the top

Article Info
Article ID : 919284
Revision : 3
Created on : 7/25/2006
Published on : 7/25/2006
Exists online : False
Views : 455