I want to compile App_GlobalResources/Strings.resx into my assembly (and eventually use satellite assemblies for Strings.es.resx, Strings.fr.resx, etc.) but the following error occurs once the app is published:
"Could not load file or assembly 'App_GlobalResources' or one of its dependencies. The system cannot find the file specified."
Steps to Reproduce:
HomeController.Index()
, e.g. ViewData["Message"] = Strings.MyTest
Can ASP.NET MVC projects use string resources compiled into the dll and if so, what am I doing wrong?
Update: Here is what I see in Reflector:
So why is the ResourceManager not finding them? Isn't it supposed to fallback to the main assembly by default?
Resource Files A resource file is an XML file that contains strings that can be translated into different languages. Resource files in ASP.NET have a . resx extension.
Open Solution Explorer add files you want to embed. Right click on the files then click on Properties. In Properties window and change Build Action to Embedded Resource.
Here's a good starting point http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx
I setup a project just like you mentioned and got precisely the same error when I deployed to IIS6. Changing Custom Tool
to PublicResXFileCodeGenerator
and Custom Tool Namespace
to Resources
per Scott's suggestions cleared it right up.
I'd also follows Scott's lead with respect to eliminating App_GlobalResources but I got it to work just fine. That might be a matter of personal preference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With