Working with Resource Files on Visual Studio

I had an unusual problem recently that took way too long for me to solve. I was trying to add resource files to a Silverlight project for the purposes of future proofing our application to be localizable, and to make maintaining strings like Tooltips easier. However, even while following the official documentation from Microsoft, I couldn’t get the damn thing to work.

Specifically, when I tried to add the Resource file to my Silverlight project (using these instructions), I couldn’t have it generate code. It wouldn’t generate any code, but what’s worse, it didn’t provide an error (or even a warning or message) when it failed.

The problem appears to be that the instructions say to right click on the project and add the Resource file using the normal “Add new…” function of Visual Studio. However, at least on Silverlight projects, these files are not placed under the “Resources” folder like they’re supposed to be. You need to create the Resources folder, and right click on THAT folder when you add the Resource file.

I ended up basically finding this by accident when looking through examples and I finally noticed that these other people all had their resx files in Resource folders, so if you’re having trouble with code-generation of resx files in Visual Studio 2008, just make sure they were in the right location, because you’re not likely to get anything to help you from Visual Studio.