views:

513

answers:

2

A web app that I'm writing throws this compiletime error

Error 1 The type or namespace name 'Web' does not exist in the namespace 'ATS.System' (are you missing an assembly reference?)

for every code file in the assembly the namespace is imported in every file (both System and System.Web)

I've also added references (to both) in the References Dir in VS

I don't know what I'm doing wrong

+1  A: 

I suspect the problem is that you've got a namespace called ATS.System - that's going to confuse things in some cases. If you possibly can, rename the namespace to something else.

Here's some example showing the same problem:

// Foo.cs
namespace ATS.System
{
    class Foo {}
}

// Bar.cs
namespace ATS
{
    using System.Collections.Generic;

    class Bar {}
}

If you move the using directive out of the namespace declaration, i.e. change the second file to:

// Bar.cs
using System.Collections.Generic;
namespace ATS
{        
    class Bar {}
}

then it's okay - but I wonder whether the autogenerated code for ASP.NET puts the using directives inside the namespace declaration instead :( Getting rid of ATS.System is certainly going to make it easier going forward though.

Jon Skeet
I don't know why, but the system generated a namespace: ATS.System.Masters for one of my files. I changed that back to ATS and it worked brilliantly. Thank you.
Matt Dunnam
@kev thanks. That teaches me why i knew a folder named "system" was a bad idea!
Matt Dunnam
@Matt - If the project's default namespace is ATS and you have a folder path '/System/Masters' off of the root of the project folder, when you add a source file to 'Masters' VS will automatically append the folder path to the default namespace: ATS.System.Masters. Just a thought as to why
Kev
..this may have happened. Oh for editable comments :)
Kev
A: 

You have a namespace "ATS.System" that is conflicting with the namespace "System". When the compiler sees "System.Web", it thinks that "System" refers to the "ATS.System" namespace.

Rename the ATS.System namespace if possible, or use an alias for it. Something like:

using AtsSys = ATS.System;

Or:

Imports AtsSys = ATS.System

That would of course mean that you would have to put AtsSys. before every class name that you use from that namespace.

Guffa