Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 332
Captain Comic Avatar asked Jan 14 '11 11:01

Captain Comic


1 Answers

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"

like image 151
dzendras Avatar answered Sep 20 '22 18:09

dzendras