如何使用“resx中嵌入的资源”中的资源?
我的 Visual Studio 解决方案有两组具有不同持久类型的资源:
Visual Studio 2010 中似乎存在一个错误,我无法从嵌入在 resx 集中选择资源:
我如何说服视觉工作室2010年让我在项目中使用资源吗?
当然,我可以在运行时设置图像:
public ImportNSAKnownTerroristsListForm()
{
InitializeComponent();
toolStripButton1.Image = Properties.AvatarSharedResources.NewDocument;
}
但我不愿意这样做。
嵌入式资源
嵌入式资源如果您必须在多个项目之间共享应用程序资源 (.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:
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.
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):
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是共享
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.