Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio creates invalid Resx files

I have a pretty simple form that I am wanting to localize (I actually have quite a few in this project, they all have the same problem). When I set the form property Localizable to true Visual Studio generates a .resx file with the form name (as you would expect). The problem though is that it's adding all sorts of things to the .resx file that nothing else can open (eg WinRes, ResEx, Simple Resx Editor, RESX Editor etc).

The error I get is:

ResX file Type System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a the data at line 125, position 4 cannot be located. Line 127, position 5. cannot be parsed.

Line 124 to 127 is:

<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="lblUsername.Location" type="System.Drawing.Point, System.Drawing">
  <value>26, 24</value>
</data>

Now I'm assuming that Visual Studio is adding this so that I can move buttons etc around depending on the language (I don't need or want this ability). However, it throws the above error in every editor other than Visual Studio.

The only extensions that I have installed (according to the Extension Manager) are:

  • Highlight all occurrences of selected word
  • Microsoft Ribbon for WPF (which I'm not using in this project)

Add-in manager shows no Add-ins.

Edit:

After digging around and manually editing the .resx file, the problem is actually with line 124 <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> specifically with Version=4.0.0.0.

If I set this to Version=2.0.0.0 then everything works, both in Visual Studio, and in all the external programs. The problem with this though is that if I edit anything within Visual Studio it will reset it back to Version=4.0.0.0.

For the time being I am going to set the Target Framework to .NET Framework 3.5 Client Profile so that Visual Studio doesn't override the version. This is a workaround and means that I can't use .NET 4.0 features.

Am I right in guessing that there's either a bug in the .NET Framework, or every single .resx editor out there (including Microsoft's).

Edit 2: It turned out that when I was trying to use Microsoft's WinRes.exe tool I was actually launching the .NET Framework 3.5 version, since the .NET Framework 4.0 version doesn't get installed.

I had to install the .NET Framework 4.0 SDK from http://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/winsdk_web.exe and I was then able to edit the .resx files with WinRes.exe 4.0

like image 767
Blair McMillan Avatar asked Nov 09 '10 09:11

Blair McMillan


People also ask

What is RESX file in Visual Studio?

resx resource file format consists of XML entries that specify objects and strings inside XML tags. One advantage of a . resx file is that when opened with a text editor (such as Notepad) it can be written to, parsed, and manipulated.

Are RESX files compiled?

resx files are compiled into binary . resources files.


1 Answers

Visual Studio creates correct *.resx files. The problem is, tools that you are attempting to use were created for previous version of the specification. That's why your workaround works.

Please check if there are no newer versions or patches to localization tools you are using.

like image 183
Paweł Dyda Avatar answered Sep 20 '22 11:09

Paweł Dyda