Could not find any resources appropriate for the specified culture or the neutral culture

64,458

Solution 1

I think simpler solution would be to create separate resources file for each language.

As far as this case is concerned check if the assembly containing resources has the default namespace set to the same text (Project->Properties->Default namespace; in VS)

Check as well if the resx file has a property BuildAction set to "Embedded resource"

Solution 2

I'm sure you've already got the answer, but just in case:

  1. You can view your ManifestResourceName by calling

    System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames() 
    

    Check that Manifest name and your name in GetString() calling are identical.

  2. Also, be sure you have correct namespace in designer.resx file:

    namespace Jfc.TFSAddIn {
    ...
    global::System.Resources.ResourceManager temp = 
                 new global::System.Resources.ResourceManager(
                 "Jfc.TFSAddIn.CommandBar", typeof(CommandBar).Assembly);
    ... 
    }
    
  3. Open resx file properties: "Build Action" should be "Embedded Resource"

Solution 3

Sounds similar to an issue we had. The namespace was incorrect in the resource file's designer. I fixed it by manually re-running the custom-tool on the resx file.

Right click your.resx, and click Run Custom Tool.

Solution 4

For me, the source of the problem was naming the rex files starting with a number:

20160216_tranlation.resx

I had to add an underscore _ before the resx file name when calling GetGlobalResourceObject:

public static string getResource(string key)
{
    return HttpContext.GetGlobalResourceObject("_20160216_tranlation", key).ToString();
}
Share:
64,458
Captain Comic
Author by

Captain Comic

I am interested in C#, .NET, algorithms, and finance.

Updated on July 04, 2020

Comments

  • Captain Comic
    Captain Comic almost 4 years

    I have created an assembly and later renamed it.

    Then I started getting runtime errors when calling:

    toolsMenuName = resourceManager.GetString(resourceName);
    

    The resourceName variable is "enTools" at runtime.

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

    The code:

    string resourceName;
    ResourceManager resourceManager = new ResourceManager("Jfc.TFSAddIn.CommandBar", Assembly.GetExecutingAssembly());
    
    CultureInfo cultureInfo = new CultureInfo(_applicationObject.LocaleID);
    
    if(cultureInfo.TwoLetterISOLanguageName == "zh")
    {
         CultureInfo parentCultureInfo = cultureInfo.Parent;
         resourceName = String.Concat(parentCultureInfo.Name, "Tools");
    }
    else
    {
         resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools");
    }
    
    toolsMenuName = resourceManager.GetString(resourceName); // EXCEPTION IS HERE
    

    I can see the file CommandBar.resx included in the project, I can open it and can see the "enTools" string there. It seems that either resources are not included into assembly or resource are included but .NET cannot resolve the name.

  • Captain Comic
    Captain Comic over 13 years
    "check if the assembly containing resources has the default namespace set to the same text (Project->Properties->Default namespace; in VS)" - the same text of what?
  • Andiih
    Andiih over 12 years
    +1 for 'Check as well if the resx file has a property BuildAction set to "Embedded resource"' = Facepalm
  • Ian Newson
    Ian Newson about 9 years
    This was my issue. Looks like ReSharper had renamed the namespace during a refactor...
  • Mystic Lin
    Mystic Lin about 8 years
    GetManifestResourceNames() is very helpful! Thank you a lot.
  • Phillip Davis
    Phillip Davis about 8 years
    I was able to solve this problem by just adding an additional entry into the resources. That forced the designer code to rebuild itself and correct the namespace issue.
  • Daniel Hillebrand
    Daniel Hillebrand over 5 years
    Same issue here. The compiled Designer.cs still had the old namespace after moving the resource to a different project. Running the custom tool fixed it. THANKS!
  • Sam
    Sam almost 3 years
    Wow!!! I scratching my hair why it doesn't work and I found that my namespace is wrong using System.Reflection.Assembly.GetExecutingAssembly().GetManifes‌​tResourceNames(). Thank you so much!