Changing the namespace of automatically generated resource classes when .RESX files are built by Visual Studio
Posted: (EET/GMT+2)
When it comes to localizing your desktop .NET applications, the basic way of supporting localized strings in C# applications is to use .RESX files. These XML files are automatically built by Visual Studio into satellite assemblies, and are deployed as DLL files along with the main application.
When a .RESX is built, Visual Studio (well, MSBuild really) generates a static helper class for you, which you can use in code to referrer to the strings stored inside the .RESX file. This is all well, until you start playing around the namescapes inside your application.
I was recently working on a desktop application that was to be renamed to match the new marketing name. The namespaces in all .CS source code files were diligently removed, but resources suddenly stopped working. We investigated this, but found out the reason soon: the .RESX designed namespace was left unchanged, and we changed this. Problem solved!
So, to be able to change the namespace generated into the resource designed file, go to the project's settings, and change the default namespace. Then, rebuild your project, and the default namespace is changed.
If you have a resource file named MyStrings.resx, then the designed file will be named MyStrings.Designer.cs. The namespace at the beginning of this file respects the project's default namespace setting, in addition to the possible folder structure in your project.
Hope this helps!