当我向现有 resx 文件添加或更改字符串时,相应的 designer.cs 文件变为空 (0 KB) 并且项目不再编译:
error CS0234: The type or namespace name 'Properties' does not exist in the namespace 'Hundegger.Gui' (are you missing an assembly reference?)
不过,一切似乎都很好。
来自 .csproj 文件:
<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 个字符串。
前段时间我们将项目转换为目标 .net framework 4.5.2(之前使用的是 4.0)。
同解决方案中的另一个项目(也转为4.5.2)没有这个问题。一旦 resx 文件中的字符串被修改/添加,设计器文件就会重新生成并且不为空。我注意到 .csproj 文件与 resx 文件没有区别。
我正在使用 Visual Studio 2013。
谢谢!
编辑 - 到达某处!!
我遇到了另一个问题,这给了我一个主意。 Visual Studio 2010 doesn't generate Resource (Resx) designer code if file is localized
似乎 resx 文件名中的某些扩展名导致 VS 无法生成相应的 designer.cs 文件。
上一个问题提到了本地化扩展:fr, en, de, etc...
但是:Gui有同样的效果。
如果我将 resx 文件重命名为 Hundegger.Gui2.resx,那么一切正常。
我可以通过在 VS 2013 中创建一个空项目来验证这一点。如果 resx 文件名以 .gui 或 .job 结尾,则不会生成设计器文件。
这一定是不久前更改的,否则不会生成现有的设计器文件。
所以我想为了避免此类问题,请避免使用“.”。在 resx 文件名中。
所以我想为了我们的目的,我们将不得不重命名 resx 文件。
最佳答案
我可以在 VS 2015 中重现相同的行为。但是如果你删除 resx 文件中的点,一切正常。所以请将 Hundegger.Gui.resx
更改为 HundeggerGui.resx
关于c# - 设计器 resx 文件仍然为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35351003/