1
votes

How to read strings from the MyResource.resx file from c#. I am not calling this from the asp.net page, rather i am calling from my bussiness logic.

Assembly assembly = this.GetType().Assembly;
ResourceManager resourceManager = new ResourceManager("MessagesResource", assembly);
resourceManager.GetString("SCHEME_UNQ");

here i am getting exception,

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

How can i fix this issue????

1

1 Answers

3
votes

Once you add a resx file to your project, Visual Studio will automatically generate a designer class which allows you to read value (In the properties of the resx file you must have Custom Tool: ResXFileCodeGenerator). For example if you add Messages.resx to your project you could directly read values from it:

string value = Messages.SomeResourceKey;