views:

650

answers:

3

Okay I'm completely stuck on this compilation error. It's a Web Site (not web app), .NET 2.0.

I have a file in this directory: welcome_teams

file name: default.aspx

Page Declaration:

<%@ Page Language="C#" MasterPageFile="~/masters/Site.master" 
AutoEventWireup="true"    CodeFile="default.aspx.cs" 
Inherits="welcome_teams_default" %>`

Code Behind

public partial class welcome_teams_default : System.Web.UI.Page

And I keep receiving this error: Make sure that the class defined in this code file matches the 'inherits' attribute

I've tried deleting the file, and adding it again as "new item" and no matter what, the error persists.

Any ideas?

Thanks!

A: 

You should check the default.designer.cs file, and make sure it also has the same class name. Sometimes, if a designer.cs file exists, and is manually edited (but sometimes for other reasons), the sync between the .aspx page and the code behind can become broken. To see the .designer.cs file, you will need to show hidden files in your project.

jrista
I don't think WebSite projects have .designer files
Jack Marchetti
You may be correct...it has been years since I last used a "Web Site" project rather than a "Web App" project. However, I do definitely remember that "Web Site" projects were about the buggiest thing Microsoft ever added to Visual Studio, and we moved away from them for very good reason. It is entirely possible you are running into one of the many extremely annoying bugs that plauge Web Site projects.
jrista
Don't I know it. My first order of business is to get this converted to a web application, with the quickness!
Jack Marchetti
sure they have like Default.aspx.designer.cs, it is where all controls (asp.net) are declared.
TheVillageIdiot
WebSite projects don't include designer files. Web Applications do.
Jack Marchetti
right click project and see if it is showing option to convert to wep app.
TheVillageIdiot
VillageIdiot might have hit the nail on the head. I remember in VS2k5 we had to download the Web Site to Web App converter. However in VS2k8, I believe it is built in. You should be able to convert via the right-click menu.
jrista
A: 

Most probably as your file is in a folder inside web root, when you create it VS changes namespace for generated files. Like, if your site name is MyWebsite then default namespace for it is MyWebsite;

namespace MyWebsite

but for your aspx file inside welcome_teams it should be:

namespace MyWebsite.welcome_teams

so in your aspx page try changing:

<% Page ...  inherits="welcome_teams_default" %>

to

<% Page .. Inherits="MyWebsite.welcome_teams.welcome_teams_default" %>
TheVillageIdiot
site doesn't use namespaces
Jack Marchetti
A: 

So, it had nothing to do with namespaces, it has to do with the default2.aspx page, pointing to the default.aspx page.

The default2.aspx page's CodeFile attribute was set to "default.aspx.cs" which screwed it all up.

For anyone who might have this problem in the future though, you can sometimes solve it by changing CodeFile to CodeBehind.

Also, in theory it was a namespace issue, but god do I hate how Website projects handle namespaces.

Jack Marchetti