如何在 C++/CLI 应用程序中正确设置根命名空间属性?
我在 Visual Studio 2008 中有一个 C++/CLI 应用程序,其命名空间遵循 CompanyName.TechnologyName[.Feature][.Design]
的 .NET 准则。问题是,似乎没有办法在项目的 Root Namespace 属性中设置多级命名空间。我已经尝试了 CompanyName.TechnologyName
和 CompanyName::TechnologyName
。
似乎我不能在不是根命名空间的命名空间内拥有 Form 控件,因为这会导致找不到它使用的资源,因此对我来说,似乎不可能遵循他们的指南并与我的 C# 应用程序保持一致。
有没有办法设置此属性以使用多级命名空间,或者我是否被迫使用只是一级的根命名空间?还是有我忽略的解决方案?
编辑:
Visual Studio 2010 中添加了允许多级根命名空间的功能。使用 CompanyName.TechnologyName
格式而不是 CompanyName::TechnologyName
。虽然后者适用于/创建/表单,但如果您的表单需要资源,则在编译时,Visual Studio 会尝试保存到 CompanyName::TechnologyName.resources
,这将引发错误。
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?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定我是否看到资源问题。不存在“根命名空间”的概念。您必须遵循命名空间声明的 C++ 规则,您必须一次嵌套一个它们。例如:
在 .cpp 文件中:
当我可以找到这样声明时,添加资源没有问题。但不要添加资源,然后更改命名空间名称。 C++ IDE 没有任何重构支持。使用 C++/CLI 进行 Windows 窗体开发并不是很流行,这可能是原因之一。
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:
And in the .cpp file:
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.