关于resources.ApplyResources的System.Resources.MissingManifestResourceException

时间:2016-03-29 00:40:52

标签: c# .net visual-studio resources manifest

以下是我挣扎的代码:

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditorPane));
this.editorControl = new EditorControl();
resources.ApplyResources(this.editorControl, "editorControl", CultureInfo.CurrentUICulture);

当代码执行时,它会抛出一个System.Resources.MissingManifestResourceException'所有错误信息都在下面。

  

类型' System.Resources.MissingManifestResourceException'的例外情况发生在mscorlib.dll中但未在用户代码中处理

     

其他信息:找不到适合指定文化或中性文化的资源。确保" Editor.EditorPane.resources"被正确嵌入或链接到汇编"编辑器"在编译时,或者所有所需的附属程序集都是可加载和完全签名的。

1 个答案:

答案 0 :(得分:1)

对我来说,问题不在于任何内部类定义。相反,问题源在项目文件中,这使我花了很多时间来找出问题。

这是我在项目文件中找到的:

<EmbeddedResource Include="Main.resx" />

这是必须的:

<EmbeddedResource Include="Main.resx">
  <DependentUpon>Main.pas</DependentUpon>
</EmbeddedResource>

如果该依赖项未在此处列出(我必须强调,我自己没有删除它-它是在MS Visual Studio的某个阶段完成的),则编译例程中未正确包含必需的资源文件。 / p>

我希望这会有所帮助(并避免其他人头痛)!

相关问题