views:

447

answers:

1

Hello,

I am having an issue when attempting to override the DisplayNameAttribute in ASP.NET MVC to provide a localized string. The code itself is straightforward and similar to that in another Stackoverflow post link text

The code works for global resources but not so well for local resources. I have a registration screen and used the Visual Studio "Generate Local Resource" command to create my local resource file. The generated file is named Registration.aspx.resx and the App_LocalResources folder is created relative to the actual Registration.aspx page - as one would expect.

However, when I attempt to get the localized string using:

ResourceManager.GetString(resourceKey)

I receive the following error message.

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

Using reflector, I can see that the file is actually Registration.aspx.resources and not Registration_aspx.resources - the underscore/period being the subtle difference

FullAssemblyName.Views.Account.App_LocalResources.Registration.aspx.resources

I have toyed with the code quite a bit but no matter what I do, the file being requested is always different than that copiled in the assembly. For instance, if i rename Registration_aspx (in the generated Registration.aspx.designer.cs class i get the same error but this time the path is "...App_LocalResources.Registrationaspx.resources"

Has anyone run into this? Is there any way I can ensure that the resource found in my assembly has this underscore?!?!?

Thank you in advance!

+1  A: 

Try Michael K. Campbell solution link text. It worked fine form me in localizing my project.

Tomcat