VS.NET 2003 keeps adding "Inherits" attribute to ASP.NET 1.1 page directives whenever changes are made, causing parser errors

Posted on 2006-11-07
Last Modified: 2008-03-10
I'm new to ASP.NET.  We are working on a project for a server running ASP.Net 1.1 and we are using Visual Studio.NET 2003 for development.  Every time I make a new .aspx web form, or make changes to an existing form, VS.NET automatically adds an "Inherits=" attribute that points to the current page.  However, when the form is run, an "Parser Error" occurs.  Take this sample page directive for an imaginary "page_name.aspx" web form of an imaginary application "my_app" in the "/current_folder/" path for example:

<%@ Page language="c#" Codebehind="page_name.aspx.cs" AutoEventWireup="false" Inherits="my_app.current_folder.page_name" %>

Accessing the form results in the following error:

Parser Error Message: Could not load type 'my_app.current_folder.page_name'.

What's interesting is that the directory structure is included in the auto-inherited class.  For example, the page in question might exist in:


and this is reflected in the Solution Explorer accordingly.  ***When this "Inherits" attribute is deleted, the form runs properly.***  But any time I add a control or make a change to the code behind file and save it, VS.NET just puts the Inherits attribute back in the directive, causing an error.  You can imagine how incredibly annoying it is to have to manually delete this automatically generated code each and every time I make a change.  I found the following topic that supports the solution of removing the "Inherits" attribute of the page directive:

But the topic does nothing to explain the behavior or how to stop it from being automatically generated, and the article linked within it ( is useless as well.  Is there any way to turn off this ridiculous behavior?  Or is there something I need to do to the project globally to make the "Inherits" attribute actually work?
Question by:tcbdata
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3

Expert Comment

ID: 17895320
Hi there,

Have you been remembering to BUILD the application after each change?  If you have C# code attached to the page, the Inherits attribute is required.  But it looks like the "My_App.dll" assembly is not in the bin\ folder of the application.  If it is not, in VS you should choose the "Build Solution" option from the Build menu and copy the bin\ folder to the server you're attempting to test with.
LVL 96

Expert Comment

by:Bob Learned
ID: 17897538
If you have a mix of namespaces, then you will get this type of problem.


Author Comment

ID: 17900926
Well, the solution won't even build at this point...but mostly due to client-side errors that VS.NET is catching (unknown CSS properties and such).  But even so, having to build the solution any time a make a minor change is made seems like overkill.  Even when I create a whole new blank solution and test project, I encounter the same problem!

Could you be more specific about a "mix" of namespaces?  I have not made any new namespaces, but VS.NET seems to be declaring them automatically in all code-behind pages.  For example, if my application name is "appname", the first line of every auto-generated code-behind after the standard "using" lines is:

namespace appname {

and then the auto-generated classes are contained inside.  While I'm new to C# and .NET, it seems to me that it's explicitly declaring the namespace "appname", and thus the aspx should see this namespace and be happy.  No?

My guess is that the problem is with our environment.  Like I said, even a new blank project exhibits this issue.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 96

Expert Comment

by:Bob Learned
ID: 17900969
If you right-click on the project in the Solution Explorer, you will see a property--Default namespace.  If you haven't changed this, then all new pages, classes, etc., that are created for the project will be assigned to the same namespace.

How many projects do you have within your solution?


Author Comment

ID: 17901542
Well, I technically have two projects in the solution.  One is a simple data utility to access our database.  The other one is the web project itself.  The "Default Namespace" was automatically populated with the application name already...the same name that it keeps trying to "Inherit".  I cleared this property and tried again, and it still adds the "Inherits" attribute to the page directive with the same namespace!
LVL 96

Accepted Solution

Bob Learned earned 500 total points
ID: 17905444
Ah, yes, the headaches of 1.1--2.0 doesn't do this, and I am not sure how to work around it.  I thought it might be a simple namespace conflict.


Author Comment

ID: 17907793
We decided to upgrade to .NET Framework 2.0, and sure enough it seems to work!  Not only is VS.NET not adding the inherits attribute when changes are mode to the code-behind C# file, but the pages that DO have it in there don't generate an error anymore.  Thanks, Bob.

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question