views:

237

answers:

4

I am having an issue trying to figure out how to appropriately name my namespace. My namespace is currently:

<CompanyName>.<ProductName>.Configuration

However, using "Configuration" conflicts with:

System.Configuration

To make matters worse, I also have a class called ConfigurationManager. I know I could change it to something like:

<CompanyName>.<ProductName>.<ProductName>Configuration

but that seems redundant. Any ideas?

EDIT: Also, I'm aware when calling either class I can fully qualify the calling code but the frequency that the classes in the System.Configuration namespace and <CompanyName>.<ProductName>.Configuration namespace will be used would make for ugly code.

EDIT2: Providing specifics:

Using statements:

using System.Configuration;
using SummitConfiguration = SST.Summit.Configuration;

Problem Line Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);

Error Message 'SST.Summit.Configuration' is a 'namespace' but it is used like a 'type' (for problem line above)

+8  A: 

Typically, in cases like this, I leave the Configuration namespace, and use an alias for accessing my namespace (instead of fully qualifying). For example:

using System.Configuration;
using PC = MyCompany.MyProduct.Configuration;

// ...

string configValue = PC.ConfigurationManager.GetValue("Foo");
Reed Copsey
This makes sense, but I'm getting 'mynamespace' is a 'namespace' but is used like a 'type' when using the System.Configuration.Configuration class. Any ideas?
Blake Blackwell
You need to provide more information - if you post your using statements (aliases + others), plus a couple lines showing the call, we can narrow it down. What I posted works very well, though - I use it always.
Reed Copsey
Sure, see above.
Blake Blackwell
Are you also "using Summit;" in there? It sounds like the compiler is finding "Configuration" and wiring it to "Summit.Configuration", which could happen with "using Summit;"
Reed Copsey
I too use namespace aliases and have had good success with this. The only problem with this approach is that the namespace alias can become a point of ambiguity when you may not need to use one in all other classes that reference the local Configuration type as opposed to the System.Configuration type. Suddenly your naming is inconsistent. If this feels offending, you'll need to rename the local Configuration class itself to something else (e.g. Config).
j0rd4n
A: 

There shouldn't be a problem with using a namespace of Configuration - you'll just need to explicitly refer to the one you want by fully qualifying the name. It's a bit of a pain but I think a clear naming convention is better than coming up with a different name if the objects in your namespace really deal with configuration. As others have suggested, you can use aliases as well.

TLiebe
+1  A: 

What about doing something like this:

using System.Configuration;
using MyCompany.MyProduct.ProdConfig

or

using System.Configuration;
using MyCompany.MyProduct.Config
Molex
A: 

This may not work for you, but when I run into this, I just rename my namespace and/or class. Something like Config.ConfigManager.

NotDan