MissingManifestResourceException是什么意思,以及如何解决它? [英] What does MissingManifestResourceException mean and how to fix it?

查看:149
本文介绍了MissingManifestResourceException是什么意思,以及如何解决它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况:

  • 我有一个名为RT.Servers的类库,其中包含一些资源(类型为byte[],但我认为这并不重要)
  • 同一个类库包含一个返回这些资源之一的方法
  • 我有一个简单的程序(带有对该库的引用),仅调用该单个方法
  • I have a class library, called RT.Servers, containing a few resources (of type byte[], but I don't think that's important)
  • The same class library contains a method which returns one of those resources
  • I have a simple program (with a reference to that library) that only calls that single method

我收到带有以下消息的MissingManifestResourceException:

I get a MissingManifestResourceException with the following message:

找不到任何资源 适合于特定的文化 或中立文化.确保 "Servers.Resources.resources"原为 正确嵌入或链接到 在编译时汇编"RT.Servers", 或所有附属装置 所需的是可加载的并且完全 签名.

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Servers.Resources.resources" was correctly embedded or linked into assembly "RT.Servers" at compile time, or that all the satellite assemblies required are loadable and fully signed.

我从没玩过文化或大会签约,所以我不知道这里发生了什么.同样,这在使用相同库的另一个项目中也有效.有什么想法吗?

I have never played around with cultures, or with assembly signing, so I don't know what's going on here. Also, this works in another project which uses the same library. Any ideas?

推荐答案

解决此问题所需要做的就是右键单击解决方案资源管理器中的Resources.resx文件,然后单击运行自定义工具.重新生成自动生成的Resources.Designer.cs文件.

All I needed to do to fix this problem was to right-click the Resources.resx file in the Solution Explorer and click Run Custom Tool. This re-generates the auto-generated Resources.Designer.cs file.

如果.resx文件是手动添加到项目中的,则该文件的自定义工具"属性必须设置为"ResXFileCodeGenerator".

If the .resx file was added to the project manually, the Custom Tool property of the file must be set to "ResXFileCodeGenerator".

问题是由于名称空间不匹配引起的,如果您在项目设置中更改了程序集的默认名称空间",则会发生此问题. (我将其从(以前)"Servers"更改为(现在)"RT.Servers".)

The problem is due to a mismatch of namespaces, which occurs if you change the "default namespace" of the assembly in the project settings. (I changed it from (previously) "Servers" to (now) "RT.Servers".)

Resources.Designer.cs中自动生成的代码中,有以下代码:

In the auto-generated code in Resources.Designer.cs, there is the following code:

internal static global::System.Resources.ResourceManager ResourceManager {
    get {
        if (object.ReferenceEquals(resourceMan, null)) {
            global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Servers.Resources", typeof(Resources).Assembly);
            resourceMan = temp;
        }
        return resourceMan;
    }
}

文字字符串"Servers.Resources"必须更改为"RT.Servers.Resources".我是手动完成的,但是运行自定义工具也可以做到.

The literal string "Servers.Resources" had to be changed to "RT.Servers.Resources". I did this manually, but running the custom tool would have equally well done it.

这篇关于MissingManifestResourceException是什么意思,以及如何解决它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆