Search code examples
c#asp.netresxaccess-modifiers

What does the Access Modifier option actually do in a RESX file?


When modifying a RESX file, I've noticed the "Access Modifier" option in the top toolbar.

enter image description here

There are three different options: public, internal, and no code generation. I'm guessing these determine which applications have access to these resource files, but I'm not exactly sure what the difference between the three options are.

  1. I would assume public resources can be accessed from any project within the solution.

  2. I would assume internal resources can only be accessed by the project in which the resource is defined.

  3. I don't know what no code generation does.

What do the three options actually mean?


Solution

  • Your assumptions about 1 and 2 are correct.

    Try setting the access modifier of a resource item which is used outside of the project in which it was defined from 'Public' to 'Internal' and then build your project again. You will get compiler errors similar to :

    error CS0122: 'Resource' is inaccessible due to its protection level

    1. 'No code generation' means a designer file like 'Resource.Designer.cs' doesn't get created:

    enter image description here