ASP.NET 强类型全球化资源值
我在从全局资源文件访问强类型值时遇到问题。 VS 2010 不提供智能感知,并且编译时失败,提示类型或命名空间不存在。这是我的代码:
lblGlobalResourceST.Text = System.Resources.GlobalResource.MyName; //MyName is the key/name
我的密钥/名称对是: MyName ,Matt
资源文件名:GlobalResource.resx 位于 root/App_GlobalResources
框架:4.0
语言:C#
根据 MSDN ,
资源被编译成 命名空间资源,以及每个默认值 资源成为成员 资源类
I'm having trouble with accessing strongly typed values from my global resource file. VS 2010 is not providing the intellisense, and it is failing while compiling, saying that the type or namespace doesn't exist. Here's my code:
lblGlobalResourceST.Text = System.Resources.GlobalResource.MyName; //MyName is the key/name
My Key/Name pair is : MyName , Matt
Resource File Name: GlobalResource.resx located in root/App_GlobalResources
Framework: 4.0
Language: C#
According to MSDN ,
Resources are compiled into the
namespace Resources, and each default
resource becomes a member of the
Resources class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我必须
在代码顶部有一个声明。
I had to have a
statement at the top of the code.
我要检查的一件事是为类设置的访问修饰符值。您将在资源编辑器的顶部找到它。确保它是公开的。
One thing I would check is the access modifier value set for the class. You will find it at the top of the resource editor. Make sure it is public.