如何使用“resx中嵌入的资源”中的资源?

发布于 2024-12-16 17:47:10 字数 1748 浏览 5 评论 0原文

我的 Visual Studio 解决方案有两组具有不同持久类型的资源

Visual Studio 2010 中似乎存在一个错误,我无法从嵌入在 resx 集中选择资源:

在此处输入图像描述

我如何说服视觉工作室2010年让我在项目中使用资源吗?


当然,我可以在运行时设置图像:

public ImportNSAKnownTerroristsListForm()
{
   InitializeComponent();

   toolStripButton1.Image = Properties.AvatarSharedResources.NewDocument;
}

但我不愿意这样做。


来自 MSDN:

嵌入式资源

嵌入式资源如果您必须在多个项目之间共享应用程序资源 (.resx) 文件,则这是最佳选择。例如,如果您有一个包含公司徽标、商标信息等的公共资源文件,则使用嵌入式资源意味着您只需复制 .resx 文件,而不需要复制关联的资源数据文件。


更新: 嵌入不同文件夹中的 .resx 资源(根据 Hans 的思考):

在此处输入图像描述


更新:有人将我的标题编辑为

  • 如何使用“resx 中嵌入的资源”中的资源?

这是不正确的,因为这会导致重复的标题,而不是正确的:

  • Visual Studio 2010:如何使用“resx 中嵌入的资源”中的资源?
  • Visual Studio 2008:如何使用“resx 中嵌入的资源”中的资源?
  • Visual Studio 2005:如何使用“resx 中嵌入的资源”中的资源?

但我不需要和巨魔进行一场小便比赛。

My Visual Studio solution has two sets of resources with different persistence types:

There seems to be a bug in Visual Studio 2010 where i cannot select resources from the embedded in resx set:

enter image description here

How do i convince Visual Studio 2010 to let me use resources in the project?


Of course i could set the images at runtime:

public ImportNSAKnownTerroristsListForm()
{
   InitializeComponent();

   toolStripButton1.Image = Properties.AvatarSharedResources.NewDocument;
}

But i'm not willing to do that.


From MSDN:

Embedded Resources

Embedded resources are the best choice if you have to share application resource (.resx) files between multiple projects. For example, if you have a common resource file that contains your company's logos, trademark information, and such, using embedded resources means you have to copy only the .resx file and not the associated resource data files.


Update: Embedded in .resx resource in different folder (per Hans' musing):

enter image description here


Update: Someone edited my title to

  • How to use resources from "Resources embedded in resx"?

This is incorrect, as that would lead to duplicated titles, rather than the correct:

  • Visual Studio 2010: How to use resources from "Resources embedded in resx"?
  • Visual Studio 2008: How to use resources from "Resources embedded in resx"?
  • Visual Studio 2005: How to use resources from "Resources embedded in resx"?

But i need to not get into a pissing match with a troll.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生再见 2024-12-23 17:47:10

答案是共享 resx 文件(和设计器)必须位于“根”文件夹中。

其他任何地方VS都找不到它。

The answer is that a shared resx file (and designer) must be in the "root" folder.

Anyplace else and VS will not find it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文