|
-
May 4th, 2009, 03:36 PM
#1
C# and resource files
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
Code:
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
Code:
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
Last edited by Suzi167; June 26th, 2009 at 10:34 AM.
-
May 4th, 2009, 04:58 PM
#2
Re: C# and resource files
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|