MissingManifestResourceException 是什么意思以及如何修复它?

发布于 2024-08-03 06:55:18 字数 425 浏览 4 评论 0原文

情况:

  • 我有一个类库,名为 RT.Servers,包含一些资源(类型为 byte[],但我认为这并不重要)
  • 相同类库包含一个返回这些资源之一的方法
  • 我有一个简单的程序(带有对该库的引用),仅调用该单个方法

我得到一个带有以下消息的 MissingManifestResourceException

找不到任何资源 适合特定文化 或中立文化。确保 “服务器.资源.资源”是 正确嵌入或链接到 在编译时组装“RT.Servers”, 或者所有卫星组件 所需的可加载且完全 已签署。

我从来没有玩过文化或集会签名,所以我不知道这里发生了什么。此外,这也适用于使用相同库的另一个项目。有什么想法吗?

The situation:

  • 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

I get a MissingManifestResourceException with the following message:

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?

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

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

发布评论

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

评论(26

情愿 2024-08-10 06:55:18

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

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

该问题是由于命名空间不匹配造成的,如果您在项目设置中更改程序集的“默认命名空间”,就会出现这种情况。 (我将其从(以前)"Servers" 更改为(现在)"RT.Servers"。)

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

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"。我手动完成了此操作,但运行自定义工具同样可以很好地完成此操作。

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.

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

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".)

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;
    }
}

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.

忘东忘西忘不掉你 2024-08-10 06:55:18

我今天刚刚遇到这个问题,我发现此 Microsoft 帮助和支持页面确实有效围绕问题。

我的文件顶部有几个委托,在全局命名空间中,突然我在运行程序时遇到了 MissingManifestResourceException ,在这一行:

this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

然后我将委托移动到命名空间,得到同样的错误。最后,我将委托放入该文件中的唯一类中,错误消失了,但我不希望委托位于该类或命名空间中。

然后我发现了上面的链接,上面写着

要解决此问题,请移动所有其他类定义,使它们出现在表单的类定义之后。

我将委托(我不会将其视为“类定义”)放在该文件的底部、本地命名空间之外,并且程序不再获得 MissingManifestResourceException 。多么令人恼火的错误。但是,这似乎是比修改自动生成的代码更强大的解决方案:)

I just came across this problem today, and I found this Microsoft Help and Support page that actually did work around the problem.

I had a couple delegates at the top of my file, in the global namespace, and all of a sudden I was getting a MissingManifestResourceException when running the program, on this line:

this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

Then I moved the delegates into the namespace, got the same error. Finally I put the delegates in the only class in that file, and the error went away, but I didn't want the delegates in that class or namespace.

Then I came across that link above, which said

To resolve this problem, move all of the other class definitions so that they appear after the form's class definition.

I put the delegates (which I would not consider "class definitions") at the bottom of that file, outside of the local namespace, and the program didn't get the MissingManifestResourceException anymore. What an irritating error. But, that seems like a more robust solution than modifying the auto-generated code :)

一杆小烟枪 2024-08-10 06:55:18

我遇到了类似的问题,虽然我知道这不是OP的原因,但我会将其发布在这里,以便如果其他人将来遇到这个问题,将会有答案。

如果您在设计器类之前添加一个类,您将在运行时收到 MissingManifestResourceException 异常(没有编译时错误或警告),因为

Visual Studio 要求设计人员使用文件中的第一个类。

有关(稍微)更多信息,请参阅 这篇文章

I've run into a similar issue and, although I know it isn't the cause the OP had, I'll post it here so that if someone else runs across this problem in the future, an answer will be available.

If you add a class before the designer class you will get a MissingManifestResourceException exception at runtime (no compile time error or warning) because

Visual Studio requires that designers use the first class in the file.

For (slightly) more information see this post.

怀念你的温柔 2024-08-10 06:55:18

我遇到了同样的问题,但是使用运行自定义工具命令作为对我的情况没有帮助。

然而,它引导我走向正确的方向,因为我最终进入了 .resx 文件的 Properties 。在这里,我注意到与另一个 .resx 文件的差异,但没有引起任何问题。

就我而言,我必须将属性“构建操作”从“资源”更改为“嵌入式资源”。

我最好的猜测是,我的 .resx 位于另一个应用程序使用的库中。我的应用程序没有自己的 .resx 文件,因此它必须使用库中的文件 - 该文件仅在嵌入库中而不是“独立”时可用。

I had the same problem, but using the Run Custom Tool command as suggested by Timwi did not help in my case.

However it lead me into the right direction, because I ended up in the Properties of the .resx file. Here I noticed a difference to another .resx file that caused no problems.

In my case I had to change the property "Build Action" from "Resource" to "Embedded Resource".

My best guess for the reason is, that I had the .resx in a library that was used from another application. My application did not have its own .resx file, so it had to use the one from the library - which is only available when it's embedded in the library and not "stand alone".

神经大条 2024-08-10 06:55:18

当我在 Vs 2012 中运行类似的问题时,结果发现 resx 文件的“自定义工具命名空间”属性是错误的(在我的例子中,实际上它是未设置的,因此生成的代码在运行时会产生此异常) 。
我的 resx 文件的最终属性集如下所示:

  • 构建操作:嵌入式资源
  • 复制到输出目录:不复制
  • 自定义工具:ResXFileCodeGenerator strong>
  • 自定义工具命名空间:My.Project.S.Proper.Namespace

When I run in a similar issue, in Vs 2012, it turned out that the "Custom Tool Namespace" property of the resx file was wrong (in my case, actually, it was unset, so the generated code yeld this exception at runtime).
My final set of properties for the resx file was something like this:

  • Build action: Embedded Resource
  • Copy to Output Directory: Do not copy
  • Custom Tool: ResXFileCodeGenerator
  • Custom Tool Namespace: My.Project.S.Proper.Namespace
温柔戏命师 2024-08-10 06:55:18

另请参阅:使用 MSBuild 构建后运行测试时出现 MissingManifestResourceException ( .mresource 在清单中有路径)

我在这里重复答案只是为了完整性:

似乎将 LogicalName 添加到项目文件可以修复它:

<LogicalName>$(RootNamespace).Properties.Resources.resources</LogicalName> 

即项目文件中的嵌入式资源条目如下所示:

<ItemGroup>
  <EmbeddedResource Include="Properties\Resources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    <LogicalName>$(RootNamespace).Properties.Resources.resources</LogicalName> 
  </EmbeddedResource>
</ItemGroup>

详细信息如下: http://blogs.msdn.com/b/msbuild/archive/2007/10/19/manifest-resource-names-changed-for-resources-files.aspx

请注意,我们使用的是 .resx 文件,但该错误似乎仍然出现。

更新:资源(包括 XAML)的问题似乎与输出路径以及正斜杠或反斜杠的使用有关,详细信息如下:
为什么修改项目输出目录会导致:IOException was unhandled "无法找到资源“app.xaml”。”

Also see: MissingManifestResourceException when running tests after building with MSBuild (.mresource has path in manifest)

I repeat the answer here just for completeness:

It appears adding LogicalName to the project file fixes it:

<LogicalName>$(RootNamespace).Properties.Resources.resources</LogicalName> 

i.e. so the embedded resource entry in the project file looks like this:

<ItemGroup>
  <EmbeddedResource Include="Properties\Resources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    <LogicalName>$(RootNamespace).Properties.Resources.resources</LogicalName> 
  </EmbeddedResource>
</ItemGroup>

This is detailed in: http://blogs.msdn.com/b/msbuild/archive/2007/10/19/manifest-resource-names-changed-for-resources-files.aspx

Note that we are using a .resx file, but the bug still appears to occur.

Update: The problem with resources (incl. XAML) appears to be related to output paths and the use of forward or backward slashes as detailed in:
Why does modifying project output directories cause: IOException was unhandled "Cannot locate resource 'app.xaml'."

忱杏 2024-08-10 06:55:18

我遇到了这个问题的另一个原因,它与 resx 文件无关。我有一个类库,其中 AssemblyInfo.cs 包含以下内容:

[assembly: ThemeInfo(
ResourceDictionaryLocation.SourceAssembly,
ResourceDictionaryLocation.SourceAssembly)]

该程序集不包含任何 WPF 代码、主题或资源字典。我通过删除 ThemeInfo 属性摆脱了异常。

我没有得到真正的异常,只是

“System.Resources.MissingManifestResourceException”类型的第一次机会异常。

查看异常详细信息,系统正在请求 MyAssembly.g.resources

I ran into a different cause of this problem, which was unrelated to resx files. I had a class library where AssemblyInfo.cs contained the following:

[assembly: ThemeInfo(
ResourceDictionaryLocation.SourceAssembly,
ResourceDictionaryLocation.SourceAssembly)]

The assembly did not contain any WPF code, theme or Resource dictionaries. I got rid of the exception by removing the ThemeInfo attribute.

I did not get an actual exception, only

A first chance exception of type 'System.Resources.MissingManifestResourceException'.

Viewing exception details, the system was requesting MyAssembly.g.resources

剩一世无双 2024-08-10 06:55:18

不确定它会对人们有帮助,但这对我有用:

所以我遇到的问题是我收到以下消息:

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

我试图获取嵌入在我的程序集中的资源 我解决这个问题的方法是将“项目”

->“属性”->“资源”选项卡中的访问修饰符从“内部”(只能在同一个类库中访问)设置为“公共”(可访问)来自另一个类库)

然后运行并瞧,对我来说不再有错误......

Not sure it will help people but this one worked for me :

So the issue I had was that I was getting the following message:

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

I was trying to get the resources that were embedded in my project from another class library.

What I did to fix the problem was to set the Access Modifier in the tab Project->Properties->Resources from "Internal" (accessible only within the same class library) to "Public" (accessible from another class library)

Then run and voilà, no more error for me...

悲歌长辞 2024-08-10 06:55:18

我遇到了同样的问题,但就我而言,我在用户控件中放置了一个与用户控件相关的类,如下所示

Public Class MyUserControlObject

end Class

Public Class MyUserCOntrol

end Class

解决方案是将 MyUserControlObject 移动到 Usercontrol 类的末尾,如下所示

Public Class MyUserCOntrol

end Class

Public Class MyUserControlObject

end Class

I had the same issue, but in my case I placed a class in a usercontrol which is related to the usercontrol like this

Public Class MyUserControlObject

end Class

Public Class MyUserCOntrol

end Class

The solution was to move the MyUserControlObject to the end of the Usercontrol class, like this

Public Class MyUserCOntrol

end Class

Public Class MyUserControlObject

end Class
瑶笙 2024-08-10 06:55:18

将项目从 VS2005 移植到 VS2010 后,出现 MissingManifestResourceException 错误。我没有在包含 Form 类的文件中定义任何其他类。我还正确设置了 resx 资源文件名。没用。

所以我删除了resx文件并重新生成它们。现在一切都好了。

I was getting the MissingManifestResourceException error after I ported my project from VS2005 to VS2010. I didn't have any other classes defined in the file that contains my Form class. And I also had my resx Resource File Name set correctly. Didn't work.

So I deleted the resx files and regenerated them. All good now.

£噩梦荏苒 2024-08-10 06:55:18

最近遇到了同样的问题,挣扎了一下,找到了这个主题,但没有答案对我来说是正确的。

我的问题是,当我从 WPF 项目中删除主窗口(它没有主窗口)时,我忘记从 App.xaml 中删除 StartupUri。我想如果您在 StartupUri 中出现错误,则可能会发生此异常,因此如果有人遇到此问题 - 检查 App.xaml 中的 StartupUri代码>.

Recently ran into the same problem, struggled for a bit, found this topic but no answers were correct for me.

My issue was that when I removed main window from my WPF project (it does not have a main window), I forgot to remove StartupUri from App.xaml. I guess this exception can happen if you have a mistake in StartupUri, so in case if anybody is struggling with this - check your StartupUri in App.xaml.

总以为 2024-08-10 06:55:18

最近偶然发现了这个问题,就我而言,我做了一些事情:

  1. 确保 resx 文件的 Designer.cs 文件中的命名空间一致

  2. 确保程序集的默认命名空间(右键单击项目并选择“属性”)设置为与资源文件所在的命名空间相同。

执行步骤 2 后,异常就消失了。

Recently stumbled upon this issue, in my case I did a few things:

  1. Make sure the namespaces are consistent in the Designer.cs file of the resx file

  2. Make sure the default namespace of the Assembly(right click the project and choose Properties) is set the same to the namespace the resources file is in.

Once I did step 2, the exception went away.

梦巷 2024-08-10 06:55:18

当我在文件中的派生自 Form 的类之前添加另一个类时,我遇到了这个问题。问题解决后添加。

I had this problem when I added another class in the file just before the class which derived from Form. Adding it after fixed the problem.

时间海 2024-08-10 06:55:18

当您将新类放入设计器创建的表单类的源代码中时,可能会出现相同的错误。

这个新类可以被删除,并放置在不同的 cs 文件中。

The same error may occur when you put a new class into the source code of a designer created form's class.

This new class may be removed, and placed in a different cs file.

逆蝶 2024-08-10 06:55:18

因为我正在预编译我的Web应用程序(使用VS2012发布功能)。我收到上面的错误。我尝试了所有建议,但奇怪的是,将“构建操作”更改为“内容”就成功了!

Because I am pre-compiling my web application (using VS2012 publish feature). I was getting the error above. I tried all the suggestions, but weirdly changing 'Build Action' to 'Content' did the trick!

生生漫 2024-08-10 06:55:18

就我而言,我有一个包含资源的 Web api,并从中创建一个 nuget 包。当我在其他项目中使用这个 nuget 时,我意识到当我请求带有资源的 api 时,经过一番研究后我收到了 MissingManifestResourceException ,我了解到 nuget 打包器不会自动打包资源。如果您想使用资源文件,则必须手动执行此操作。因此,您需要将以下行添加到 .nuspec 文件中:
(访问 https://github.com/NuGet/Home/issues/1482

<package> 
    <metadata>
    </metadata>
    <files>
        <file src="bin\Debug\en\MyAssembly.resource.dll" target="lib\net40\en\MyAssembly.resource.dll" />
        <file src="bin\Debug\es\MyAssembly.resource.dll" target="lib\net40\es\MyAssembly.resource.dll" />
    </files>
</package>

但是,在添加文件之前,您需要确定您使用的是哪个版本的 .net。

In my case, I have a web api with resources and I create a nuget package from that. When I use this nuget in other projects, I realise that when I request a api with resources, I am getting MissingManifestResourceException after a bit reasearch, I learn nuget packager is not packing resources automatically. If you want to use resources files, you have to do that manually. So you need to add below lines to your .nuspec file:
(Visit https://github.com/NuGet/Home/issues/1482)

<package> 
    <metadata>
    </metadata>
    <files>
        <file src="bin\Debug\en\MyAssembly.resource.dll" target="lib\net40\en\MyAssembly.resource.dll" />
        <file src="bin\Debug\es\MyAssembly.resource.dll" target="lib\net40\es\MyAssembly.resource.dll" />
    </files>
</package>

But, before adding files, you need to be sure which version of .net you are using.

丢了幸福的猪 2024-08-10 06:55:18

我有一个新创建的 F# 项目。
解决方案是在项目属性 -> 中取消选中“使用标准资源名称”应用->资源/指定如何管理应用程序资源。
如果您没有看到该复选框,请更新您的 Visual Studio!我安装了15.6.7。在 15.3.2 中,此复选框不存在。

I had the with a newly created F# project.
The solution was to uncheck "Use standard resource names" in the project properties -> Application -> Resources / Specify how application resources will be managed.
If you do not see the checkbox then update your Visual Studio! I have 15.6.7 installed. In 15.3.2 this checkbox is not there.

Hello爱情风 2024-08-10 06:55:18

在重命名全局命名空间(不是手动,而是使用 VS2017 的重命名工具)后,我在基于 WinForms 的托管 C++ 项目中遇到了这个问题。

解决方案很简单,但其他地方没有提到。

您必须更改 vcxproj 文件中的 RootNamespace 条目以匹配 C++ 命名空间。

I've encountered this issue with managed C++ project based on WinForms after renaming global namespace (not manually, but with Rename tool of VS2017).

The solution is simple, but isn't mentioned elsewhere.

You have to change RootNamespace entry in vcxproj-file to match the C++ namespace.

猥琐帝 2024-08-10 06:55:18

就我而言,这是从 Winforms Form 打开的窗口的 Xaml 中的拼写错误:

不正确:

正确:<图像源 =“../Resources/WorkGreen.gif”/>
它可能会帮助某人

In my case it was a typo in the Xaml of a window opened from Winforms Form:

Incorrect: <Image Source="/Resources/WorkGreen.gif"/>

Correct: <Image Source="../Resources/WorkGreen.gif"/>
It may help someone

川水往事 2024-08-10 06:55:18

如果您在使用 CMake 生成 C# 项目时遇到此问题,我找到的解决方案可能会对您有所帮助。

显然,您的 CMakeLists.txt 文件需要

set_property(TARGET yourTargetName PROPERTY VS_GLOBAL_RootNamespace yourRootNamespace)

将您自己的值替换为 yourTargetNameyourRootNamespace

然后资源将嵌入到您的程序集中!

If you're getting this while generating a C# project using CMake, the solution I found may help you.

Your CMakeLists.txt file needs

set_property(TARGET yourTargetName PROPERTY VS_GLOBAL_RootNamespace yourRootNamespace)

Substitute your own values for yourTargetName and yourRootNamespace, obviously.

Then the resources will get embedded in your assembly!

深爱不及久伴 2024-08-10 06:55:18

出现此错误的另一个原因是“.resx”文件从项目中排除。

就我而言,“.resx”文件已从项目中排除。

  1. 在解决方案资源管理器中选择“显示所有文件”选项。
  2. 右键单击“.resx”文件,然后单击“包含在项目中”。

重建项目/解决方案。

One more reason to get this error is- '.resx' file excluded from project.

In my case, '.resx' file was excluded from project.

  1. Select 'show all files' option in solution explorer.
  2. Right click on '.resx' file(s) and click include in project.

Rebuild the project/solution.

就是爱搞怪 2024-08-10 06:55:18

我阅读了所有答案,但没有任何对我有用。我的情况很可能不同,但同样的错误。我的问题是我有两个项目。第二个项目从第一个项目中添加了很多表单作为“添加为链接”。

对于 WinForms,需要 3 个文件:代码、设计器和资源文件。如果您通过“添加为链接”同时添加所有 3 个文件,Visual Studio 不会将它们以相同的形式链接在一起。它将编译并运行,但会因相同的 MissingManifestResourceException 错误而崩溃。

修复:您必须按顺序单独执行它们:代码文件 -->设计师文件 -->资源文件。然后它们被分组,不再有错误,至少对我来说是这样。

I read all the answers and nothing worked for me. Most likely my situation is different, but same error. My issue was that I had two projects. Second project had a lot of forms added to it from the first one as "Add as link".

For WinForms, there are 3 required files: the code, the designer, and the resource files. If you add all 3 files at the same time as "Add as link", Visual Studio does not link them together as same form. It will compile, and run, but it will blow up with the same MissingManifestResourceException error.

Fix: You have to do them individually, in order: code file --> designer file --> resource file. Then they are grouped and no more error, at least for me.

为你鎻心 2024-08-10 06:55:18

我们在将解决方案从 .NET 4.8 升级到 6,然后又降回 4.8 后遇到了这个问题。我们的 VB.net 项目中的自定义用户控件的文件名是 LinearVoltMeter.vb(.designer.vb 和 .resx),但位于 Our.Namespace.LinearVoltGauge 的命名空间中。我们将错误跟踪到这一行:

Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)

重命名文件(以及控制)以匹配命名空间 LinearVoltGauge,解决了该问题。

We came across this after upgrading a solution from .NET 4.8 to 6 and then back down to 4.8. A custom user control in our VB.net project had the filename of LinearVoltMeter.vb (.designer.vb, and .resx), but was in the namespace of Our.Namespace.LinearVoltGauge. We traced the error to this line:

Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)

Renaming the file (and hence control) to match the namespace, LinearVoltGauge, fixed the issue.

眼前雾蒙蒙 2024-08-10 06:55:18

就我而言,我更改了项目名称空间,因此我的解决方案抛出“missingmanifestresourceexception”异常。

我没有在解决方案资源管理器中右键单击 .resx 文件并单击“运行自定义工具”选项,而是替换了
rootnamespace 到 .csproj 文件(RootNamespace)中的新命名空间并再次重建解决方案。

所有 Resources.Designer.cs 文件命名空间都会自动更改为新的命名空间。

In my case I have changed my project namespace and hence my solution was throwing "missingmanifestresourceexception" exception.

Instead of right clicking the .resx file in the solution explorer and clicking on "Run Custom Tool" option, I have replaced the
rootnamespace to new namespace in .csproj file(RootNamespace) and rebuilded the solution again.

All Resources.Designer.cs files namespaces got automatically changed with new namespace.

剧终人散尽 2024-08-10 06:55:18

如果您使用常量或文字,请确保它引用 ProjectName.Resources 形式的资源,并且不 cpntain Resources.resx

If you use a constant or literal, make sure it refers to a resource of the form ProjectName.Resources, and does not cpntain Resources.resx.

七色彩虹 2024-08-10 06:55:18

来自Microsoft 支持页面

如果您使用的附属程序集中存在本地化资源,而该附属程序集是通过文件名不正确的 .resources 文件创建的,则会出现此问题。如果您手动创建附属程序集,通常会出现此问题。

要解决此问题,请在运行 Resgen.exe 时指定 .resources 文件的文件名。当您指定 .resources 文件的文件名时,请确保该文件名以应用程序的命名空间名称开头。例如,在 Microsoft Visual Studio .NET 命令提示符处运行以下命令来创建一个 .resources 文件,该文件的文件名开头包含应用程序的命名空间名称:

Resgen strings.CultureIdentifier.resx 
MyApp.strings.CultureIdentifier.resources

From the Microsoft support page:

This problem occurs if you use a localized resource that exists in a satellite assembly that you created by using a .resources file that has an inappropriate file name. This problem typically occurs if you manually create a satellite assembly.

To work around this problem, specify the file name of the .resources file when you run Resgen.exe. While you specify the file name of the .resources file, make sure that the file name starts with the namespace name of your application. For example, run the following command at the Microsoft Visual Studio .NET command prompt to create a .resources file that has the namespace name of your application at the beginning of the file name:

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