Click to See Complete Forum and Search --> : C# and resource files


Suzi167
May 4th, 2009, 03:36 PM
Hello,

I have an application which we want to be able to localize relatively easy. That is why I am using resouce files.

I am however experiencing the following issue:

The name of the assembly is xxx.Web

I have 2 resource files called xxx.resx and
xxx.resx

In my application's pre-build events I have

resgen xxx.resx
resgen xxx.es-ES.resx


which generates the two resource files

xxx.es-ES.resources
xxx.resources

Also when I build the application I get a folder under the Bin folder named es-ES since that is one of the cultures.


So far so good. When I run my code though I get the following exception:

MissingManifestResourceException

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


Here is my code:

since this is an MVC application in the Global.asax I have then following


private void SetLocalization()
{
////For now this is hard coded but in the future when more languages are introduced
////the language setting will be read from a config. file.
string strCulture = "es-ES";
CultureInfo objCI = new CultureInfo(strCulture);
Thread.CurrentThread.CurrentCulture = objCI;
Thread.CurrentThread.CurrentUICulture = objCI;
}




Then I have a helper function


public static string GetResourceMessage(this HtmlHelper helper,string messageName)
{
ResourceManager rm = new ResourceManager("xxx.strings",
Assembly.Load("xxx.Web"));

return rm.GetString(messageName);
}




when the program tries to execute the GetSTring() that's when the exceptino is raised.

What am I missing????


Thanks very much in advance

Susan

JonnyPoet
May 4th, 2009, 04:58 PM
maybe this helps
http://www.codeproject.com/KB/aspnet/localizationByVivekTakur.aspx