Search code examples
c#embedded-resource

Missing manifest error when trying to retrieve resource via resource manager


I'm having a few troubles with getting resources dynamically as I get "Missing manifest" errors. I looked up a few possible causes and did what was written there but so far nothing worked.

Currently I have this situation: The resx file I'm trying to access is: "Resources/Messages.resx" (thus in a nonstandard folder.

The code I'm using is this:

ResourceManager resourceManager = new ResourceManager("Resources.Messages", this.GetType().Assembly);
resourceManager.GetString("ResourceText" + MessageType + "Subject")

with messageType being a string. On the second line I get the error message.

The status of the resource file is this:

  • Build Aciton: Embedded Resource
  • Custom Tool: PublicResXFileCodeGenerator
  • Access Modifier Public

The resfile has 2 variants: Messages.res and Messages.de.resx with the same names for each row and also the same general properties (the "GetString" also definitively tries to access the correct name).

So my question is what I'm doing wrong there and what can I do to correct this problem?


Solution

  • Found the problem. For new ResourceManager not only the namespace of the resourcesfiles has to be given but also the default namespace. Thus if the application has a default namespace of: MyApplication.MyServerApp then instead of "Resources.Messages" one must put in: "MyApplication.MyServerApp.Resources.Messages" leading to the following functioning sourcecode:

    ResourceManager resourceManager = new ResourceManager("MyApplication.MyServerApp.Resources.Messages", this.GetType().Assembly);
    resourceManager.GetString("ResourceText" + MessageType + "Subject")