VS2008发布网站后无法解析全局资源
我有一个在 VS 2008 中运行的 Web 项目。我们在 App_GlobalResources 文件夹中有一些用于国际化的全局资源文件 (*.resx)。 所有这一切对我在 VS 中安装的本地 IIS 来说就像一个魅力。
但是当我将我的网络项目发布到本地文件系统和/或另一台服务器时,所有资源都无法再找到。 所以我猜预编译在某种程度上破坏了东西。 当我调用预编译的web时,我得到一个错误,找不到带有键xyz的资源对象,尽管之前可以找到它。
我使用 .NET Reflector 检查了资源内容是否已进入 *.dll。 所有这些标识符都在那里(bin/Web.dll、bin/
<asp:MenuItem NavigateUrl="~/OrderNew.aspx" Text="<%$ Resources:MyProject, MenuNewOrder %>" Value="NewOrder">
资源文件称为 MyProject.resx 和 MyProject.
有什么想法如何解决这个问题吗?
我真的很感谢任何帮助。
谢谢
编辑:
如果我手动将 App_GlobalResources 文件夹复制到输出中,资源可能会正常加载。 所以我真的很想知道这个预编译是关于什么的。
我仍然对“以正确的方式”解决问题感兴趣。
I have a web-project running in VS 2008. We have some global resource files (*.resx) in the App_GlobalResources folder for internationalisation. All this works like a charm on my local IIS installation out of VS.
But when I publish my web-project to the local filesystem and/or another server, all the resources can no longer be found. So I guess the pre-compilation is somehow corrupting stuff. When I call the pre-compiled web, I get an error that the resource object with key xyz cannot be found, although it could be found before.
I checked with .NET reflector if the resource stuff made it into the *.dlls. All those identifiers are there (bin/Web.dll, bin/<culture>/Web.resources.dll). The identifiers are loaded like this:
<asp:MenuItem NavigateUrl="~/OrderNew.aspx" Text="<%$ Resources:MyProject, MenuNewOrder %>" Value="NewOrder">
The resource files are called MyProject.resx and MyProject.<culture>.resx where <culture> corresponds the the specific culture (i.e. MyProject.de-DE.resx).
Any ideas how to solve this?
I really appreciate any help.
Thanks
Edit:
If I copy the App_GlobalResources folder manually to the output, the resources may be loaded normally. So I really really wonder what this pre-compilation is all about.
I'm still interested in solving the issue "the right way".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了同样的问题,必须对 resx 文件属性进行两项更改。
I had the same issue and had to make two changes to the resx file properties.
(我无法对之前的答案发表评论......还没有声誉......?)
恐怕这并没有解决我的问题。
当尝试“始终内容/复制”解决方案时,我收到一个异常,说编译时的链接不起作用。
为什么asp.net在资源编译进去的时候需要resx文件!?
(I can't comment on the previous answer...no reputation yet...?)
This did not solve my problem, I'm afraid.
When trying the "Content/Copy Always" solution I get an exception saying that the linking at compile time did not work.
Why does asp.net need the resx file when the resources are compiled in!?
从另一个项目复制资源文件时出现此错误。
我通过删除全局资源、添加新资源并将
data
元素从旧 XML 复制到新 XML 来解决此问题。这会导致资源的以下设置:
I had this error when copying a resource file from another project.
I solved this by deleting the global resource, adding a new resource and copying the
data
elements from the old to the new XML.This results in the following settings for the resource:
我遇到过同样的问题。 每当我将应用程序发布到小型企业服务器(SBS2008)时,它都会停留在控件名称行上,但实际上停留在它的 meta:resourcekey 部分上。 上述解决方案都没有帮助我。
我花了 6 个小时解决这个问题,最后我意识到这是在我在服务器上进行一些文件夹清理时发生的。 一开始,我的所有应用程序都位于 E: 的文件夹中,但后来我创建了名称指示应用程序 ApplicationPools 的文件夹,并将相应的应用程序移动到那里。
我不知道 IIS7 如何在我的 SBS 上寻找资源文件,但这肯定是问题所在。 当我带着我的应用程序回到 E: 时,一切都开始像魅力一样工作。
I had the same issue. Whenever I published my app to the Small Business Server (SBS2008) it stuck on control name line but in fact on meta:resourcekey part of it. Non of the above mentioned solution helpd me.
I spent 6 hour figuring this out, finally I realised that this happend when I did some folder cleenup on the server. At the begning all my apps was located on E: in their folders but then I have created folders with names indicating to apps ApplicationPools and I move coresponding apps there.
I dont know how IIS7 on my SBS looking for resource files but definitely this was the issue. When I get back with my apps to E: again all started working like a charm.