Designer resx文件保持为空 [英] designer resx file remains empty

查看:119
本文介绍了Designer resx文件保持为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我向现有的resx文件添加或更改字符串时,相应的designer.cs文件变为空(0 KB),并且项目不再编译:

When I add or change a string to an existing resx file the corresponding designer.cs file becomes empty (0 KB) and the project no longer compiles:

错误CS0234:类型或名称空间名称属性"不存在 在名称空间"Hundegger.Gui"中(您是否缺少程序集 参考?)

error CS0234: The type or namespace name 'Properties' does not exist in the namespace 'Hundegger.Gui' (are you missing an assembly reference?)

一切似乎都很好.

从.csproj文件中:

From the .csproj file:

<Compile Include="Properties\Hundegger.Gui.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Hundegger.Gui.resx</DependentUpon>
    </Compile>

<EmbeddedResource Include="Properties\Hundegger.Gui.resx">
  <Generator>PublicResXFileCodeGenerator</Generator>
  <LastGenOutput>Hundegger.Gui.Designer.cs</LastGenOutput>
</EmbeddedResource>

任何想法可能有什么问题吗??? resx文件非常简单.目前仅包含10个字符串.

Any ideas what could be wrong??? The resx file is rather simple. Currently just contains 10 strings.

有时候,我们将项目转换为目标.net Framework 4.5.2(以前使用的是4.0).

Sometime ago we converted the project to target .net framework 4.5.2 (previously was using 4.0).

同一解决方案中的另一个项目(也已转换为4.5.2)不存在此问题.一旦修改/添加了resx文件中的字符串,就会重新生成设计器文件,并且该文件不为空.我发现.respro文件中的.csproj文件没有区别.

Another project in the same solution (which was also converted to 4.5.2) does not have this problem. As soon as a string in a resx file is modified/added the designer file is regenerated and is not empty. I notice no difference in the .csproj files concerning the resx files.

我正在使用Visual Studio 2013.

Am using Visual Studio 2013.

谢谢!

编辑-到达某个地方!

我遇到了另一个问题,这给了我一个主意. Visual Studio 2010不会如果文件已本地化,则生成资源(Resx)设计器代码

I ran into this other question and that gave me an idea. Visual Studio 2010 doesn't generate Resource (Resx) designer code if file is localized

似乎resx文件名中的某些扩展名导致VS无法生成相应的designer.cs文件.

It seems that certain extensions in the resx file name cause VS to NOT generate the corresponding designer.cs file.

上一个问题提到了本地化扩展名:fr,en,de等...

The previous question mentions localization extensions: fr, en, de, etc...

但是:Gui具有相同的作用.

However: Gui has the same effect.

如果我将resx文件重命名为Hundegger.Gui2.resx,则一切正常.

If I rename the resx file to Hundegger.Gui2.resx then everything works just fine.

我可以通过在VS 2013中创建一个空项目来验证这一点.如果resx文件名以.gui或.job结尾,则不会生成设计器文件.

I could verify this by creating an empty project in VS 2013. If the resx file name ends with .gui or .job then the designer file is not generated.

此更改必须在不久之前完成,否则将不会生成现有的设计器文件.

This must have changed not too long ago, otherwise the existing designer files would have not been generated.

因此,我想为了避免此类问题,请避免使用.".在resx文件名中.

So I guess that in order to avoid such problems, avoid using '.' in the the resx file name.

所以我想出于我们的目的,我们将不得不重命名resx文件.

So I guess for our purpose we will have to rename the resx files.

推荐答案

我可以在VS 2015中重现相同的行为.但是,如果删除resx文件中的点,则一切正常.因此,请从Hundegger.Gui.resx更改为HundeggerGui.resx

I can reproduce the same behavior in VS 2015. But if you remove the dot in the resx file everything it working fine. So please change from Hundegger.Gui.resx to HundeggerGui.resx

这篇关于Designer resx文件保持为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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