为什么是用不同的名字在文件中的资源文件生成的类? [英] Why is the generated class for a resource file in a file with a different name?

查看:180
本文介绍了为什么是用不同的名字在文件中的资源文件生成的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个资源文件strings.resx,生成的资源类是在strings1.designer.cs。为什么会出现这样的情况?该问题特别是在1。该文件中的类名是弦,因为它应该是。

I have a resource file strings.resx, and the generated resource class is in strings1.designer.cs. Why is this the case? The problem specifically is the "1". The class name inside that file is "strings", as it should be.

请注意,我也尝试删除designer.cs和保存文件RESX再生,但并没有改变任何东西。

Note that I did try deleting the designer.cs and regenerating it by saving the resx file, but that didn't change anything.

推荐答案

我只是碰到了这个问题,发现的.csproj文件中的问题。看来,Visual Studio中保存它上次使用的文件名,并试图再次使用该文件名来生成。所以,如果出于某种原因在 Strings.designer.cs 是以往一样产生的 Strings1.designer.cs 它看起来像VS将继续使用Strings1。

I just ran into this problem and found the issue inside the .csproj file. It appears that Visual Studio saves the last filename it used and attempts to generate using that filename again. So if for some reason the Strings.designer.cs is ever generated as Strings1.designer.cs it looks like VS will continue to use Strings1.

下面你可以看到这是给我一个问题的.csproj文件的部分。最重要的是< LastGenOutput> 在其中 Strings1.designer.cs 保存结束。

Below you can see the portions of the .csproj file that was giving me an issue. Most importantly the <LastGenOutput> at the end where Strings1.designer.cs is saved.

<Compile Include="App_GlobalResources\Strings.Designer.cs">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="App_GlobalResources\Strings.es.designer.cs">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>Strings.es.resx</DependentUpon>
</Compile>
...
<ItemGroup>
  <EmbeddedResource Include="App_GlobalResources\Strings.es.resx">
    <Generator>GlobalResourceProxyGenerator</Generator>
    <LastGenOutput>Strings.es.designer.cs</LastGenOutput>
  </EmbeddedResource>
  <EmbeddedResource Include="App_GlobalResources\Strings.resx">
    <Generator>GlobalResourceProxyGenerator</Generator>
    <LastGenOutput>Strings1.designer.cs</LastGenOutput>
  </EmbeddedResource>
</ItemGroup>

更改&LT; LastGenOutput&GT; 以下解决我的问题:

&LT; LastGenOutput&GT; Strings.designer.cs&LT; / LastGenOutput&GT;

这篇关于为什么是用不同的名字在文件中的资源文件生成的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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