Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

designer resx file remains empty

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.

like image 667
santiagoIT Avatar asked Feb 11 '16 22:02

santiagoIT


2 Answers

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

like image 98
Matthias Avatar answered Sep 20 '22 15:09

Matthias


Yes, Designer resx file remains empty.
you should follow the below steps, it will work 100%.
1) Create Resource.resx file under any folder

2) set CustomTools = PublicResXFileCodeGenerator and
Build Action = Embedded Resource in Resource.resx file property.

3) Now create the different language files like below,
Resources.en-US.resx
Resources.nl-NL.resx  etc

4)If MVC, in your MVC Model refer this namespace as project.folder

5) change the one of the property as below (example)

     [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MMM/yyyy}"), Display(Name = "dtMovinDate",ResourceType = typeof(Resources.Resource))]
                public DateTime dtMovinDate { get; set; }

6)

     In config file add this under System.web

        <globalization enableClientBasedCulture="true" culture="en-US" uiCulture="en-US" />

7) rebuild the project and test it.

It will work. The real reason of designer.cs file empty is resource designer.cs will refer these files based on your web.config file.
like image 24
Sud Avatar answered Sep 24 '22 15:09

Sud