ASP.NET application w/CSLA framework; Visual Studio 2008
I have a class library of business objects. I am storing the broken rules strings in the Resource file associated with the project (My Projects > Resources.resx). I added开发者_Python百科 a new resx file to the project and named it Resources.fr-CA.resx to store the french language equivalents of the rules.
I am calling the strings with the My.Resources object, like this:
e.description = My.Resources.BrokenRulesString
This works like a charm when I run the application locally (i.e. hit "play" in Visual Studio). However, when I build and deploy the application to another environment I always get the values in the default resource file.
Even if I explicitly set the culture to "fr-CA" in the Resources.Designer.vb file, like this, the property returns the string from the default resource file:
Public ReadOnly Property BrokenRulesString() As String
Get
Return ResourceManager.GetString("BrokenRulesString", "fr-CA")
End Get
End Property
It looks to me like the application can't see the fr-CA resource file so defaults to the... default file. Any tips to get this working?
Thank you.
You need to make sure the satellite assembly containing your localized strings is deployed in the correct directory structure. See this MSDN article for details.
From the article:
After you have compiled your satellite assemblies, they all have the same name. The runtime differentiates between them based upon the culture specified at compile time with Al.exe's /culture option and by each assembly's directory location. You must place your satellite assemblies in expected directory locations.
Ultimately it came down to the fact that I hadn't added the proper Project Output Group (Localized resources) for the Business.Library project to the setup project. I added it to the bin folder and now the deployed application works like a charm as well.
Oded, thanks for getting my head pointed in the right direction. Cheers!
精彩评论