views:

152

answers:

1

I have a C++/CLI application in Visual Studio 2008 whose namespace follows the .NET guideline of CompanyName.TechnologyName[.Feature][.Design]. The problem is that there seems to be no way to set a multi-level namespace in the project's Root Namespace property. I have tried both CompanyName.TechnologyName and CompanyName::TechnologyName.

It seems that I cannot have a Form control inside a namespace that is not the root namespace as this causes the resources it uses to not be found, thus to me it seems impossible to follow their guideline and be consistent with my C# applications.

Is there a way to set this property to use multi-leveled namespaces or am I forced to use a root namespace that is simply one-level? Or is there a solution that I am overlooking?

Any help would be appreciated.

Thanks

Edit: Functionality is added in Visual Studio 2010 to allow multi-level root namespaces. Use CompanyName.TechnologyName format NOT CompanyName::TechnologyName. While the latter works for /creating/ forms, if your forms require resources then when compiling, Visual Studio tries to save to CompanyName::TechnologyName.resources which will throw an error.

A: 

Not sure I see the resource problem. There is no notion of a "root namespace". You have the follow the C++ rules for namespace declarations, you'll have to nest them one at a time. For example:

namespace Contoso {
  namespace Accounting  {
    namespace PayRoll {
      namespace Employees {

  // class declarations go here

}}}}  // yeah, that sux

And in the .cpp file:

using namespace Contoso::Accounting::PayRoll::Employees;

There's no trouble adding resources when it is declared like this that I could find. But don't add a resource, then change the namespace name. The C++ IDE has no refactoring support whatsoever. Windows Forms development in C++/CLI isn't very popular, this would perhaps be one reason.

Hans Passant
Somehow restarting Visual Studio and re-compiling fixed the problem. Thanks for your reply. :)
Matthew Bowen