Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Resource files (resx) namespace and access modifier

People also ask

What is a resources RESX file?

resx resource file format consists of XML entries, which specify objects and strings inside XML tags. It contains a standard set of header information, which describes the format of the resource entries and specifies the versioning information for the XML used to parse the data.


The quick answer is: Just open the Properties of the resource file and change the Custom Tool Namespace to the namespace you need.
Simple as that.


I'm not entirely sure where the problem lies yet, but I can tell you that you can solve it by changing the tool used to generate the code.

When I tried to follow this article, I also stumbled onto this problem. After downloading the source files as the author suggested, I noticed that the resource file that were already present had the following class in the "Custom Tool" property: "PublicResXFileCodeGenerator". Also, the "Build Action" property was set to "Embedded Resource", but I'm not sure if that's part of the problem.

Any new resource file that I created used the custom tool "GlobalResourceProxyGenerator". After overwriting this with the aforementioned "PublicResXFileCodeGenerator" seemed to solve the problem, whatever the real problem may be.

I also noticed that the present resource file was in the "2.0" format, whereas new files were in the "1.3" format. You can see this when you open the resx file using an XML editor (or by using "open with" from visual studio itself).

I hope you can make it work like this, it's not ideal though. It's likely to be an installation issue with Visual Studio 2008 and SP1, or something like that.

Update:

This blog entry may also help.


Or you can change the CustomTool attribute (tested in VS2010).

You just have to open the file properties of the resource file and change the “Custom Tool” from “GlobalResourceProxyGenerator” to “PublicResXFileCodeGenerator”, which is the default Tool for local resource files. Next you have to change the “Build Action” to “Embedded Resource”. You may also want to assign a proper Custom Tool Namespace like “Resources” in order to access the file properly, but this isn’t necessary...

Source


The resx picks up the namespace depending on the namespace specified in your Visual Studio project configuration. Update your project to have the right namespace, and the resx should inherit it (new ones for sure, not sure if existing ones will be fixed - they should).