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?
Solution 1If it has an "include" option, click that, and it should fix it. If it doesn't, you need to find out where that class is, and add a reference to uit, either via the project in the same solution, or via the DLL, and then add the appropriate using line to the top of all files that reference it.
To do it, you may either manually type the Using Namespace or you just right click on the class name and select Resolve > Namespace. But using “Ctrl+.” you can automatically add the namespace in your code.
Namespaces organize the objects defined in an assembly. Assemblies can contain multiple namespaces, which can in turn contain other namespaces. Namespaces prevent ambiguity and simplify references when using large groups of objects such as class libraries.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With