tags:

views:

1110

answers:

7

I am currently trying to cleanup a bit of a corporate website that I inherited here. I managed to clean up most of the errors in the website but something is still up here.

I have one masterpage that have this code :

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage {
    public lists m_listsClass = new lists();

(no it's not a typo the S in lists).

Now in App_code I have one class lists.cs

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for lists
/// </summary>
public class lists
{
    public lists()
    {

When I try to build the website in visual studio 2008 I have this error :

Error   3 The type or namespace name 'lists' could not be found (are you missing a using directive or an assembly reference?) C:\Users\egirard\Documents\Visual Studio 2008\Projects\iFuzioncorp\iFuzioncorp\Masters\MasterPage.master.cs 23 12 iFuzioncorp

Am I missing something ?

Also I saw some strange behaviour on the server. Apparently according to IIS7 it is compiling using .net 2.0 (the pool is configured with .net 2) but there are some "using" statements that include Linq ... how is it possible to compile the page if Linq is not part of the .net 2 itself ?

Just edited with news details on the code itself. No namespace at all everywhere.

+1  A: 

include the namespace under which lists calss is defined

or

define both the master page and lists class under the same namespace

Rony
there is no namespace defined for the list class itself and the masterpage
Erick
does your master page inherits from another class?
Youssef
wrap the lists class under a namespace and include it in the masterpage
Rony
@youssef the typical System.Web.UI.MasterPage
Erick
namespace MyNamespace{public class lists{ public lists().....using System.Web.UI.HtmlControls;using MyNamespace;public partial class MasterPage : System.Web.UI.MasterPage { {
Rony
A: 

Make sure that in your masterpage, you have an #include statement for the namespace that the lists class is a part of (if they're in seperate namespaces, the masterpage isn't going to automatically pick up on it).

As for the strange server side behavior, .NET 2.0, 3.0, and 3.5 all run inside of .NET 2.0 app pools in IIS. It looks strange at first, but you get used to it. Here's a link with a little more in-depth explination:

The Way I See It: Where is ASP.NET 3.5 on IIS?

Justin Niessner
A: 

In order to use a type, you must reference the assembly which defines it and include the appropriate namespace.

Using only includes namespaces, if you don't use any types from said namespaces it has no effect.

Brian Rasmussen
A: 

is lists.cs wrapped in a namespace? if it is the case then you need to add the namespace (yournamespace.lists) or include it in masterpage. Check Also if your MasterPage is in a Namespace

Youssef
Just edited the question and nope no namespace at all.
Erick
A: 

Hi There – i had a similar problem; all my namespaces and inheritance was in place. Then i then noticed that the class file’s build action was set to “Content” not “Compile” (in the properties window.

A: 

Finally I understood quite lately that it was a website and not a web application I had to question the guys here to get it... So it's quite normal all the error I had. I haven't had the occasion to convert it first.

Erick
+1  A: 

For whatever worth might there be for an answer (possibly not the right one) after many months, i think i should contribute this:

There is a case that this happens, when you place a web site inside another (ie in a subfolder). In that case, the only App_Code folder that is legitimate is the App_code folder of the outer web site. That is, the App_Code folder right under the root of the master web site.

Maybe (say maybe) there should be no need to transform your web site to a web application, if you place the class file inside the App_code folder of the ROOT web site.

daskd