How to set a top-level namespace when you've defined a root namespace?

J

Jeff Brown

Hi,

I suspect that this isn't possible, but I figured I'd ask.

My project has a root namespace, let's say it's "Root", that applies to
almost every source file (which is why I've set it as the project's root
namespace).

However, the project also includes a couple of source files whose contents
will live in an entirely different namespace, let's say the "Special"
namespace.

So, within those particular source files, I use the Namespace statement:
Namespace Special

However, this puts the code into the namespace "Root.Special", not
"Special".

Does anyone know whether it's possible to use the Namespace statement to put
something into a top level namespace, NOT within the project's root
namespace?

Thanks,
Jeff Brown
 
J

Jay B. Harlow [MVP - Outlook]

Jeff,
Does anyone know whether it's possible to use the Namespace statement to
put something into a top level namespace, NOT within the project's root
namespace?
No, when you set the project's root namespace it is set for every file!

Have you considered moving the Special namespace into its own project? As it
sounds like it is outside the namespace of the current project.

However most of my solutions, the root of all projects share a common root.

For example, in my "My Application" solution, I might have:

Solution: My Application
Folder: My Application

Project: My App
Folder: My Application\My App
Namespace: MyApp
Assembly: MyApp.exe

Project: Framework
Folder: My Application\Framework
Namespace: MyApp.Framework
Assembly: MyApp.Framework.dll


Project: Plugin1
Folder: My Application\Plugin1
Namespace: MyApp.Plugin1
Assembly: MyApp.Plugin1.dll


Project: Plugin2
Folder: My Application\Plugin2
Namespace: MyApp.Plugin2
Assembly: MyApp.Plugin2.dll


Project: Data
Folder: My Application\Data
Namespace: MyApp.Data
Assembly: MyApp.Data.dll


Project: UI
Folder: My Application\UI
Namespace: MyApp.UI
Assembly: MyApp.UI.dll



Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top