Inaccessible, Internal, Resource Files?

Oliver Spryn picture Oliver Spryn · Jul 18, 2014 · Viewed 14.9k times · Source

I am building an ASP.NET MVC 4 website with C#. I am localizing all of my static strings in a Resource File (.resx). I use the Visual Studio interface for creating and populating the resource file. In my index.cshtml view, I try to use one of the strings from the resource file, like this:

@using Namespace.To.RESX.File

...

<h1>@EN_US.GLOBAL_NAME</h1>
<h2>&ldquo;@EN_US.GLOBAL_SLOGAN&rdquo;</h2>

...

I can compile the application, but I get a runtime error when I load the page, saying:

Compiler Error Message: CS0122: 'Namespace.To.RESX.File.EN_US' is inaccessible due to its protection level

Looking in the resx designer file, I can see the class and all of its members are marked as internal. I completely understand what the C# access control modifiers do, how they work, etc... but I don't understand why Visual Studio would restrict access to the resource members like this.

Why would Visual Studio do this? Is there an (easy) way to change these access control modifiers, or am I missing the point of resource files completely?

Answer

Oliver Spryn picture Oliver Spryn · Jul 18, 2014

Yep... didn't see this. Open up the resource file in design mode and change the access modifier (at least, on VS 2013):

enter image description here