Inaccessible, Internal, Resource Files?

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?


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

链接地址: http://www.djcxy.com/p/66646.html

上一篇: 无法使用asp.net mvc中的资源文件进行本地化

下一篇: 不可访问,内部,资源文件?