Reputation: 1179
Trying to access a specific localised resource file such as WebResource.en.us
which is located in my App_GlobalResources
folder using the following code:
string resData = GetGlobalResourceObject("WebResource.en.us", "SomeResource").ToString();
but this keeps giving me the error below:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Resources.WebResource.en-us.resources" was correctly embedded or linked into assembly "App_GlobalResources.bpqqrnv4" at compile time.
Any ideas ?
Upvotes: 2
Views: 1504
Reputation: 8359
I tried the following Code
Page_Load(....)
{
/// note - i did NOT mention the culture when accesing my resourceFiles
Debug.WriteLineIf(
GetGlobalResourceObject("WebResource", "someResource")!=null,
GetGlobalResourceObject("WebResource", "someResource").ToString());
/// accessing a culture specific resource without changing Page Culture
CultureInfo yourCI = new CultureInfo("en-US");
Debug.WriteLine(
HttpContext.GetGlobalResourceObject(
"WebResource",
"someResource",
yourCI).ToString());
}
my Page directive
<% Page Culture="en-US" UICulture="en-US" ..... %>
My App_GlobalResources folder contains two files
Using this settings and code - my Debugger printed the value without any problems. When removing WebResource.resx (my default ressource file) the same code throws an exception.
I would assume that you have to add a default resx file and remove the explicit culture notation in GetGlobalResourceObject(..., ..).
update: added some code to access specific resx culture file see also MSDN
Upvotes: 2