人迹罕至,内部资源文件? [英] Inaccessible, Internal, Resource Files?
问题描述
我建立一个ASP.NET MVC 4网站用C#。我本地化我所有的静态字符串的资源文件(的.resx
)。我使用Visual Studio界面,用于创建和填充资源文件。在我的 index.cshtml
的看法,我尝试使用从资源文件中的字符串中的一个,像这样的:
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>“@EN_US.GLOBAL_SLOGAN”</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
在RESX设计文件看,我可以看到该类和其所有成员都被标记为内部
。我彻底明白什么是C#访问控制修饰符做什么,他们是如何工作的,等等...但我不明白为什么Visual Studio的限制会这样对资源的访问成员。
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.
为什么Visual Studio中做到这一点?是否有一个(简单)的方法来改变这些访问控制修饰符,还是我失去了资源的点文件完全?
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?
推荐答案
是的...没有看到这一点。打开在设计模式中的资源文件,更改访问修饰符(至少,在VS 2013):
Yep... didn't see this. Open up the resource file in design mode and change the access modifier (at least, on VS 2013):
这篇关于人迹罕至,内部资源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!