Last post May 26, 2011 02:40 AM by hidayathulla.b
May 20, 2011 03:25 PM|Peter Smith|LINK
I want to get a value from my global resource file, but also passing the correct language parameter.
Normally I retreive values like so: Resources.Glossary.title, but that doesnt give me the opportunity to pass a specific culture.
I could also do it like so:
rm.GetString("title", New System.Globalization.CultureInfo("en"))
But then I have to compile the resource files in my \bin folder and I want to retrieve them from my \App_GlobalResources\glossary.resx files
Also the GetGlobalResourceObject doesnt allow for passing a language parameter.
So is there a way to do this?
May 20, 2011 03:38 PM|Shakti Singh Tanwar|LINK
Add multiple files in \App_GlobalResources folder like \glossary.resx.en for every culture and use rm.GetString("title", New System.Globalization.CultureInfo("en"))
May 20, 2011 04:17 PM|Peter Smith|LINK
Ok, so I already have that. But what exactly do I need to load into the resource manager in global.asax?
I tried this:
Application("RM") = New ResourceManager("Glossary", Assembly.Load("Glossary"))
Then in default.aspx.vb I do: Shared rm As ResourceManager = HttpContext.Current.Application("RM")
But with the above I get:
Could not load file or assembly 'Glossary' or one of its dependencies. The system cannot find the file specified.
May 20, 2011 04:38 PM|Shakti Singh Tanwar|LINK
try Assembly.LoadFrom with full path of assembly
May 20, 2011 04:46 PM|Peter Smith|LINK
Sorry, not sure what you mean there. Does that mean I STILL have to compile the resource files?
May 26, 2011 02:25 AM|Yanping Wang - MSFT|LINK
thanks for your post.
please try to use Assembly.GetExecutingAssembly() instead of Assembly.Load().
more details please refer:
hope this helps, thanks.
May 26, 2011 02:40 AM|hidayathulla.b|LINK
//For Getting the Resource File
System.Resources.ResourceManager rsMgr = new System.Resources.ResourceManager("ClassLibraryName.ResourceFileName", System.Reflection.Assembly.GetExecutingAssembly());
// in Place of ClassLibraryName put ur ProjectName like systemframework ... and ResourceFileName like glossary //
//For getting the title string value
string value = rsMgr.GetString("title") ;
Let me know if u have any questions...