c# - How to use ResourceManager and resources file in ASP.NET? -


i have following method:

    private void setresources(string filename = resxfilename)     {         if (_resourcemanager == null)         {             _resourcemanager = new resourcemanager(filename + ".strings", gettype().assembly);         }     } 

if resxfilename = "example", example.strings.resx need located in project in order accessed? i've tried placing in properties of project under solution explorer, whenever getstring("examplestring") called , examplestring exists name , has value in example.strings.resx, following system.exception:

could not find resources appropriate specified culture or neutral culture. make sure \"example.strings.resources\" correctly embedded or linked assembly \"projectname\" @ compile time, or satellite assemblies required loadable , signed.

i've tried running custom tool , ensured build action set "embedded resource", others have posted similar issues have mentioned. these solutions have not resolved exception.

it looks need flip filename, strings filename.

as place files, depends , web project should in app_globalresources

try this

private void setresources(string filename = resxfilename) {     if (_resourcemanager == null)     {         assembly assembly = system.reflection.assembly.load("app_globalresources");         _resourcemanager = new resourcemanager("resources." + filename, assembly);     } } 

for example put strings.en-us, strings.fr resource files in app_globalresources folder.

edit:

i don't know add, correct way of doing, sake of time, created demo project you.

demo download

look inside of homecontroller see example.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -