开发者

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;
    ...
}
开发者_Python百科

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜