Global resources can't be resolved after publishing Website in VS2008
Asked Answered
H

4

13

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".

Handshaker answered 12/5, 2009 at 7:10 Comment(1)
Yours is the solution I finally came to - we seem to have to use compile action "embedded resource" to access resources from code-behind, yet the files themselves in /app_globalresources in order to access them using <%$Resources: Class, ResKey%>. Seems like there should be a better way.Displacement
T
13

I had the same issue and had to make two changes to the resx file properties.

  1. Set the "Build Action" to Content
  2. Set the "Copy to Output Directory" to Copy always
Twine answered 2/6, 2009 at 2:23 Comment(1)
This solves the problem of copying the stuff manually, although Copy if newer is sufficient for me.Handshaker
G
2

(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!?

Grenade answered 27/5, 2010 at 9:7 Comment(1)
Even though you don't have reputation, you can always comment under your questionCele
H
1

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:

  <ItemGroup>
    <Content Include="App_GlobalResources\Global.resx">
      <Generator>GlobalResourceProxyGenerator</Generator>
      <LastGenOutput>Global.Designer.cs</LastGenOutput>
    </Content>
  </ItemGroup>
Hyland answered 12/1, 2012 at 8:57 Comment(1)
Holy crap, thank you. I wish I could upvote this more than once.Laterite
D
0

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.

Deviation answered 6/2, 2013 at 15:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.