0

I´m having a strange problem with resources files. Strange because it was working great. Well, I have some resources files. I created a Resources folder on my asp.net mvc 3 project structure and I am mirroring the views's folder structure. For now I have:

Views
   Shared
      _Layout.cshtml

Resources
   Shared
      Layout.pt-BR.resx
      Layout.en-US.resx
      Layout.ko-KR.resx

All resources files are configured as Embedded Resource, PublicResXFileCodeGenerator and with Custom Tool Namespace "ViewRes". All ".Designer.cs" files are empty. I remember to see some code in them when it was working.

On my .csproj file I have these data:

<ItemGroup>
    <EmbeddedResource Include="Resources\Shared\Layout.en-US.resx">
      <SubType>Designer</SubType>
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Layout.en-US.Designer.cs</LastGenOutput>
      <CustomToolNamespace>ViewRes</CustomToolNamespace>
    </EmbeddedResource>
    <EmbeddedResource Include="Resources\Shared\Layout.ko-KR.resx">
      <SubType>Designer</SubType>
      <Generator>PublicResXFileCodeGenerator</Generator>
      <CustomToolNamespace>ViewRes</CustomToolNamespace>
      <LastGenOutput>Layout.ko-KR.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <EmbeddedResource Include="Resources\Shared\Layout.pt-BR.resx">
      <SubType>Designer</SubType>
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Layout.pt-BR.Designer.cs</LastGenOutput>
      <CustomToolNamespace>ViewRes</CustomToolNamespace>
    </EmbeddedResource>
  </ItemGroup>

The problem is: When I try to access the @ViewRes on my views, It is not recognized. I tried already to remove the custom tool namespace but the @Resource is not recognized too. In both situations I got this compilation error:

Compiler Error Message: CS0103: The name 'ViewRes' does not exist in the current context

Does anybody have any idea? Thanks, Paulo

EDIT: NEW INFORMATIONS

I created a global Resources.resx file by project's properties menu in VS2010 and it's working with the custom tool namespaces I have entered. "Resources" namespace still not working. I think the problem is with the local resources files. Unfortunatly I need them because I can't rename the global resources.resx file including the culture code.

EDIT 2 I created new .resx file on Resource folder and what I can see is that the filename can not have 2 ".". Is the name is Resources.resx, it works. If the name is Resource-en-US.resx, it works but, If the name is Resources.en-US.resx it fails!

4

1 回答 1

0

我认为您还可以编写一个自定义助手,它将通过反射返回字符串。

于 2012-08-17T14:36:06.333 回答