Doguhan Uluca
Doguhan Uluca

Reputation: 7313

Why are namespaces acting up in Visual Studio 2010?

I've just converted a project to VS 2010 and something really weird is going on with namespaces. Let me give an example, the following code used to work in VS2008:

namespace MySystem.Core.Object
{
    using MySystem.Core.OtherObject;
    ...
}

But now it doesn't, it either wants the whole thing to be put outside of the namespace like this:

using MySystem.Core.OtherObject;

namespace MySystem.Core.Object
{
    ...
}

or be rewritten it like:

namespace MySystem.Core.Object
{
    using OtherObject;
    ...
}

I understand why this works and maybe is the correct way of handling this, but now we'd have to change thousands of lines of code! Which is not cool.

Any idea to circumvent this requirement?

Upvotes: 8

Views: 1133

Answers (1)

sohtimsso1970
sohtimsso1970

Reputation: 3286

It may be because you converted to C# from VB.NET. "Usings" in VB.NET are the same thing as "Imports" in C#. So when the conversion/upgrade took place, it figured you meant to use a using(){} statement and placed that inside the namespace. Rewrite your includes as "imports" and it should work.

Upvotes: 1

Related Questions