I'm trying to use the ResourceManager in a C# class, but don't know what to substitute for the basename when creating a new instance of the ResourceManager class.
I have a separate project that contains the resource files which is referenced by my project above named as the following:
If I have a code snippet as follows, what should I substitute for the basename when I want to use the English or Spanish version of the resources?
ResourceManager RM = new ResourceManager(basename,Assembly.GetExecutingAssembly());
I tried the approach suggested by Tom, but am getting the infamous error
Could not find any resources appropriate for the specified culture or the neutral culture.
My solution has two projects where project YeagerTech is a web application and project YeagerTechResources contains all the resources. Project YeagerTech has a reference to YeagerTechResources.
I have the following syntax when creating my Resource Manager:
ResourceManager RM = new ResourceManager("YeagerTechResources.Resources", Assembly.GetExecutingAssembly());
Obviously, it's incorrect.
The resource files in the YeagerTechResources project have their BuildAction set to Embedded Resource.
The name of my resource files are: Resources.resx and Resources.es-ES.resx.
If someone can simply tell me the exact syntax to use based on my project and resource file names when instantiating the resource manager, I would greatly appreciate it...
I've done everything I can think of to resolve this and can't....
This is my last attempt to resolve it here...
ResourceManager RM = new ResourceManager("YeagerTechResources.Resources", Assembly.GetExecutingAssembly()); sb.Append(RM.GetString("RegisterThanks"));
I am getting the following error after executing the code above:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "YeagerTechResources.Resources.resources" was correctly embedded or linked into assembly "YeagerTech" at compile time, or that all the satellite assemblies required are loadable and fully signed.
I am able to use the resources in the HTML markup with absolutely no issues, but when coming to the C# code in the Controller, I keep on getting the above error.
Any help for the exact syntax I need based on my projects would be greatly appreciated.
ResourceManager(String, Assembly) looks up resources based on two pieces of information that you supply: the base name of the .resources file, and the assembly in which the default .resources file resides. The base name includes the namespace and root name of the .resources file, without its culture or extension.
Resources in . resx files. Unlike text files, which can only store string resources, XML resource (. resx) files can store strings, binary data such as images, icons, and audio clips, and programmatic objects.
The Resource File Generator (Resgen.exe) converts text (. txt or . restext) files and XML-based resource format (. resx) files to common language runtime binary (.
If you have embedded the . resources file that contains the default culture's resources in your executable and your app is throwing a MissingManifestResourceException, you can use a reflection tool such as the IL Disassembler (Ildasm.exe) to determine the fully qualified name of the resource.
There's surprisingly simple way of reading resource by string:
ResourceNamespace.ResxFileName.ResourceManager.GetString("ResourceKey")
It's clean and elegant solution for reading resources by keys where "dot notation" cannot be used (for instance when resource key is persisted in the database).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With