Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use compiled global resources in ASP.NET MVC
    primarykey
    data
    text
    <p>I want to compile <em>App_GlobalResources/Strings.resx</em> into my assembly (and eventually use satellite assemblies for <em>Strings.es.resx, Strings.fr.resx</em>, etc.) but the following error occurs once the app is published:</p> <blockquote> <p>"Could not load file or assembly 'App_GlobalResources' or one of its dependencies. The system cannot find the file specified."</p> </blockquote> <p><strong>Steps to Reproduce:</strong></p> <ol> <li>Create a new ASP.NET MVC project.</li> <li>Add an App_GlobalResources folder and a <em>Strings.resx</em> file.</li> <li>Set the file's <strong>build action to 'Embedded Resource'</strong></li> <li>Add a string to <em>Strings.resx</em> and use it in <code>HomeController.Index()</code>, e.g. <code>ViewData["Message"] = Strings.MyTest</code></li> <li>F5 to debug, works fine.</li> <li>Publish to IIS and (since <em>Strings.resx</em> is excluded from publishing) you will get the above error in the published site.</li> </ol> <p><em>Can ASP.NET MVC projects use string resources compiled into the dll and if so, what am I doing wrong?</em></p> <hr> <p>Update: Here is what I see in Reflector: <a href="https://i.stack.imgur.com/mhs2D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mhs2D.png" alt="String Resources"></a></p> <p>So why is the <a href="http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.aspx" rel="nofollow noreferrer">ResourceManager</a> not finding them? Isn't it supposed to <a href="http://msdn.microsoft.com/en-us/library/system.resources.ultimateresourcefallbacklocation.aspx" rel="nofollow noreferrer">fallback to the main assembly</a> by default? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload