【问题标题】:ResourceManager - how to find a required base name for an embedded resource file?ResourceManager - 如何为嵌入式资源文件找到所需的基本名称?
【发布时间】:2023-03-18 08:11:01
【问题描述】:

我有一个从外部文件加载资源的库,如下所示:

ResourceManager rm = ResourceManager.CreateFileBasedResourceManager(stringsFileName, ResourcesDir, null)

现在我想将加载从外部文件更改为嵌入式资源。我已将“.resources”文件附加到项目中,并将其构建操作更改为“嵌入式资源”。加载如下:

   System.Resources.ResourceManager myManager = new
                   System.Resources.ResourceManager(resName,
                   myAssembly); 

这编译得很好。但是,在运行时应用程序会报告以下错误:

找不到任何适合指定文化的资源或 中立文化。确保“Strings.3.resources”正确无误 在编译时嵌入或链接到程序集“TestApp.Resources”中, 或者所需的所有附属程序集都是可加载且完全可加载的 签名。

无论我通过什么名称都会发生这种情况,所以我的问题是如何为我刚刚嵌入的资源文件找到正确的基本名称?

【问题讨论】:

    标签: c# .net resources resourcemanager


    【解决方案1】:

    我相信资源名称是完全限定的,所以它是 {assemblyNameSpace}.Strings.3.resources。

    您可以使用 dotPeek 之类的反汇编器/反编译器来确认这一点:http://www.jetbrains.com/decompiler/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-13
      • 1970-01-01
      • 1970-01-01
      • 2013-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-09
      相关资源
      最近更新 更多