Visual Studio 2015, can't change access modifier of new resources files Visual Studio 2015, can't change access modifier of new resources files asp.net asp.net

Visual Studio 2015, can't change access modifier of new resources files


Can you check the property of your file and verify if Custom Tool is ResXFileCodeGenerator ? If it's GlobalResourceProxyGenerator, the dropdown will be disabled.


I had the same problem but I found this easy solution Visual Studio's Access Modifier drop down option is disabled for resource file

To summarize:

  1. Right click on your file resource, choose Properties (Alt+Enter)
  2. Change Build Action to Embedded Resource
  3. Change Custom Tool to PublicResXFileCodeGenerator


A) In Asp.net Core projects

This problem is a known bug in Asp.net Core projects and access modifier is on public by default and you can not change it. It will be solved by asp.net core team next updates but if you need internal access modifier you can use my temporary solution:

  1. Add your all items by the resource designer in your Resource.resx and save it
  2. In the solution explorer expand the Resource.resx tree and open Resource.Designer.cs
  3. Replace all public strings in it with internal and save it

Note: every time you save the Resource.resx file you should do the step 3 again.

Finally you should have a Resource.Designer.cs file with access modifiers like this:enter image description here

Also check the namespace in Resource.Designer.cs file. it should be a appropriate namespace. Sync with your project namespace.


B) In Normal Asp.net projects

If you have not CustomTool property in the Properties panel for your resource (.resx) file to change it to PublicResXFileCodeGenerator and solve the problem

Then you should change some settings in your project (.csproj) file manually. It's so easy, just follow my instructions:

  1. Right click on your project in solution explorer and select Unload Project
  2. Right click again on it and select Edit .....csproj
  3. In the opened .csproj file, find the .resx string, you will see a block of settings there. That is something like bellow codes.
  4. Change it to something like the following code (include PublicResXFileCodeGenerator):

.

<EmbeddedResource Include="MyResourceFile.resx">      <SubType>Designer</SubType>      <Generator>PublicResXFileCodeGenerator</Generator> <!--important line-->      <LastGenOutput>MyResourceFile.Designer.cs</LastGenOutput></EmbeddedResource>
  1. Save the edited .csproj file
  2. Right click again on your project in the solution explorer and select Reload project
  3. Now open your .resx file and enjoy ;)

Note: use your resource file name instead of MyResourceFile