% VS2010 下的某些 C++/CLI 项目属性页不支持样式宏?

发布于 2024-08-30 01:18:48 字数 1108 浏览 4 评论 0原文

我们当前正在评估 VS2010,并将 VS2008 C++/CLI 项目升级为新的 .vcxproj 格式。我注意到我们在项目设置中设置的某个属性没有正确翻译。在配置属性下 ->托管资源 ->资源逻辑名称,我们曾经(在VS2008中)设置:

$(IntDir)\$(RootNamespace).$(InputName).resources

这表明所有.resx文件都将编译到

OurLib.SomeForm.resources

程序集内部。 (编译时调试部分被删除)

根据 MSDN,$(InputName) 宏不再存在,应替换为 %(Filename)。然而,当翻译上面的行以交换这些宏时,它似乎永远不会扩展。它尝试编译的第二个 .resx 文件,我收到“LINK:致命错误 LNK1316:重复的托管资源名称 'Debug\OurLib.%(Filename).resources”。这向我表明 % 样式宏没有在这里扩展,至少在这个特定属性中是这样。

如果我们没有在该属性中设置任何内容,则默认行为似乎是将子目录添加为前缀,例如:

OurLib.Forms.SomeForm.resources

其中 Forms 是 .resx 文件所在项目的子目录。仅当 .resx 文件位于正在构建的项目的直接子目录中时,才会发生这种情况。如果 .resx 文件存在于磁盘上的其他位置(又名 ..\OtherLib\Forms\SomeForm2.resx),则不会添加此前缀。

这会导致加载表单资源时出现问题,因为它没有考虑到这种可能的前缀,即使我们使用标准表单设计器方法来获取资源:

System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(SomeForm::typeid));

并且不按名称指定 .resources 文件。

我刚刚描述的问题可能与原始问题不同,但如果我要解决资源逻辑名称问题,我认为这一切都会消失。有谁知道有关这些 % 宏以及允许在何处使用它们的信息吗?

We're currently evaluating VS2010 and have upgraded our VS2008 C++/CLI project to the new .vcxproj format. I've noticed that a certain property we had set in the project settings did not get translated properly. Under Configuration Properties -> Managed Resources -> Resource Logical Name, we used to have (in VS2008) the setting:

$(IntDir)\$(RootNamespace).$(InputName).resources

which indicated that all .resx files were to compile into

OurLib.SomeForm.resources

inside of the assembly. (the Debug portion is dropped when assembled)

According to MSDN, the $(InputName) macro no longer exists and should be replaced with %(Filename). However, when translating the above line to swap those macros, it does not seem to ever expand. The second .resx file it tries to compile, I get a "LINK : fatal error LNK1316: duplicate managed resource name 'Debug\OurLib.%(Filename).resources". This indicates to me that the % style macros are not being expanded here, at least in this specific property.

If we don't set anything in that property, the default behavior seems to be to add the subdirectory as a prefix, such as:

OurLib.Forms.SomeForm.resources

where Forms is the subdir of our project that the .resx file lives. This only occurs when the .resx file is in an immediate subdirectory of the project being built. If a .resx file exists somewhere else on disk (aka ..\OtherLib\Forms\SomeForm2.resx) this prefix is NOT added.

This is causing an issue with loading form resources, as it does not account for this possible prefix, even though we are using the standard Forms Designer method of getting at resources:

System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(SomeForm::typeid));

and do not specify the .resources file by name.

The issue I've just described may not be the same as the original question, but if I were to fix the Resource Logical Name issue I think this would all go away. Does anyone have any information about these % macros and where they are allowed to be used?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文