Type "X" does not exist in type "YZ"

Our team recently migrated from Visual Studio 2008 / .NET3.5 to Visual Studio 2010 / .NET4.0. Now VS2010 gives a strange error message. It is played using the following program:

using System;

namespace Some.Main
{
}

namespace SomeLib
{
    interface Some
    {
    }
}

namespace ConsoleApplication1
{
    using Some.Main;
    using SomeLib;

    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Press enter to continue");
            Console.ReadLine();
        }
    }
}

In VS2008, this worked fine, but in VS2010 I received the following error message:

Type name "Main" does not exist in type "SomeLib.Some"

Interestingly, if I click "Build Solution", the program will be built just fine, and I can even execute it without any problems. This is just Visual Studio, which seems to have problems with this code.

Unfortunately, I am working on an old deprecated application, and I cannot (easily) change the names of these namespaces.

, , , .

+5
3

. Some - , , / using , .

, , , global:: using ( ), :

using global::Some.Main;

UPDATE
, SO, @alex : "" ?

+9

, IntelliSense "", .

, : IntelliSense "" Some.Main Some, , , Some.

, , , , , .

IntelliSense being fooled

+4

Try the following:

using Some.Main;
using SomeLib;

namespace ConsoleApplication1
{
    // instead of placing usings here.
}
+1
source

All Articles