1

I've been trying to get a string from resources file:

var resourceManager = new ResourceManager(typeof(Properties.Settings));
var recent1 = resourceManager.GetString("recent1");

But I got an exception:

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

How do I fix it?

1
  • 1
    You can use var str = Properties.Resources.recent1; to obtain the string value instead. When adding a string to the resources the template uses internal static signature for the property. Commented Jan 3, 2021 at 8:51

1 Answer 1

3

For retrieve string from .resx file don't no need to create the ResourceManager class instance. The template uses internal static signature for the property when adding a string to the resources. Therefore the resource can be obtained directly:

var recent = Properties.Resources.recent1; 

And here's an example how do get the string by creating instance of the ResourceManager when required to obtain resource for specific culture:

ResourceManager rm = new ResourceManager("WpfApp11.Properties.Resources", typeof(Properties.Resources).Assembly);
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
var recent1 = rm.GetString("recent1");

For additional information see ResourceManager.GetString Method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.