Changing Resource files (resx) namespace and access modifier

Viewed 58903

In my webproject I'm using 4 resources files in my App_GlobalResources folder. One of them (lang.resx) has been created before my arrival on the project. It has the correct namespace (WebApplication.App_GlobalResources) and access modifier : public.

On the other hand, the three others Resource files that I just created have a different namespace (Resources) and internal access modifier, and I can't change it on the Resource File Form from Visual Studio because it's disabled. If I try to change it directly in the designer.cs file, the modifications are cancelled on the next save of the file.

It's not a critical bug but it can be misleading for the others developers on the project to find different namespaces and access modifiers for the resources files they will use.

5 Answers

Resource Files access modifiers are in the .csproj;

Changing directly the .csproj file should workaround this problem.

Look for the <Generator> element and set its value in accordance to the examples below:

A resource file with internal modifier looks like this,

<ItemGroup>
 <EmbeddedResource Update="resources.resx">
  <Generator>ResXFileCodeGenerator</Generator>
  <LastGenOutput>resources.Designer.cs</LastGenOutput>
 </EmbeddedResource>
</ItemGroup>

where a resource file with public modifier looks like this.

<ItemGroup>
 <EmbeddedResource Update="resources.resx">
  <Generator>PublicResXFileCodeGenerator</Generator>
  <LastGenOutput>resources.Designer.cs</LastGenOutput>
 </EmbeddedResource>
</ItemGroup>
Related