C# – designer resx file remains empty

cvisual studio

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:

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

Everything seems to be just fine, though.

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>

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

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

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.

Am using Visual Studio 2013.

Thanks!

EDIT – getting somewhere!!

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

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

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

However: Gui has the same effect.

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

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.

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

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

Best Answer

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

Related Topic