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:
- Right click on your file resource, choose Properties (Alt+Enter)
- Change Build Action to Embedded Resource
- 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:
- Add your all items by the resource designer in your
Resource.resx
and save it - In the solution explorer expand the
Resource.resx
tree and openResource.Designer.cs
- Replace all
public
strings in it withinternal
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:
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 theProperties panel
for your resource (.resx
) file to change it toPublicResXFileCodeGenerator
and solve the problemThen you should change some settings in your project (
.csproj
) file manually. It's so easy, just follow my instructions:
- Right click on your project in
solution explorer
and select Unload Project - Right click again on it and select Edit .....csproj
- In the opened
.csproj
file, find the.resx
string, you will see a block of settings there. That is something like bellow codes. - 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>
- Save the edited
.csproj
file - Right click again on your project in the
solution explorer
and select Reload project - Now open your
.resx
file and enjoy ;)
Note: use your resource file name instead of
MyResourceFile