The resource object with key '' was n

2019-07-19 01:47发布

问题:

I have an ASP.NET MVC 3 application that I have localized using LocalResources. Everything (as always) works on my machine but when the application gets deployed (by tfs auto-deploy) to my testing environment I get the following error:

The resource object with key '' was not found

My resources files (in App_LocalResources folders) are marked as EmbeddedResources, they have custom tool associated with them and their accesibility is set to Public.

When I look at what is being deployed to the testing then the only hint of resources I see are some culture specific bolders in /bin (ie /bin/en that contains one .dll).

My gut tells me that I am somehow missing default resources.

What am I missing?

回答1:

Contrary what every tutorial in the internet tells you you do not need to set Build Action to EmbeddedResource. In my case I got my code to work by setting it to Content. This way the resource files are deployed alongside your code.



回答2:

I normally use App_GlobalResources for multi-language files. You can also right click properties on the resx and change the Build Action to Embedded Resource which hopefully should include it into the output as expected.