ResourceManager尝试加载.resources而不是.resx文件 [英] ResourceManager trying to load .resources not .resx file

查看:209
本文介绍了ResourceManager尝试加载.resources而不是.resx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方式在.net网站中加载resx文件:

I am trying to load a resx file in my .net website using:

ResourceManager rm = new ResourceManager( "Project.Resource", Assembly.GetExecutingAssembly() );

Resource.resx文件位于App_LocalResources文件夹中,并设置为在构建时嵌入到程序集中。

The Resource.resx file is in the folder App_LocalResources and is set to be embedded in assembly on build.

当我尝试使用以下方式访问resx文件时:

When I try to access the resx file using:

rm.GetString( key); rm.GetString( key,culture);

我收到一条错误消息:


找不到适合于指定区域性
或中立文化。确保
Project.Resource.resources在编译时已正确嵌入或链接到
程序集 Project中,或
要求所有附属程序集
是可加载的,并且已完全签名

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Project.Resource.resources" was correctly embedded or linked into assembly "Project" at compile time, or that all the satellite assemblies required are loadable and fully signed.

请注意.resources ...对这里发生的事情有任何想法吗?

Notice the .resources ... any ideas on what is going on here?

推荐答案

我认为您使用ResourceManager的方式是错误的。
请参阅此帖子

I think the way you are using ResourceManager is wrong. See this post.

还请注意,当您打开Visual Studio命令提示符时,&运行resgen.exe,说它用于将资源文件从一种格式转换为另一种格式(即resx转换为资源)。
我认为,您需要将文件从resx&然后使用resourceManager加载它。

Also note, when you open Visual Studio command prompt, & run resgen.exe, it says its used to convert resource files from one format to another (i.e. resx to resources). I think, you will need to convert your file to resources from resx & then load it using resourceManager.

这篇关于ResourceManager尝试加载.resources而不是.resx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆