开发者

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:

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


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.


Sometimes in specific cases the windows forms designer crashes during validating the form with the *.resx files.

Controls where a DataSource was attached are affected from this behavior. In my case I got some DataSets as DataSource for Grids, Combos...

So I have opened the Designer and it't telling me it cannot open due a problem with a control named: blabla

after checking the designer-file I found out nothing is wrong with the control it's just the *.resx file pointing to a wrong source, because I refactored the DataSet. So the *.resx has not updated due this refactoring.

I opened the *.resx file and simply searched for the identifier of the control and found a Base64 encoded code. Deleting the value inside the block without deleting the surround tags will resolve the problem for this control as the windows forms designer will automatically refresh and readd the missing content to the *.resx file.


In the .resx, locate the first line of the base64 encoded string. The end should be "j00LjAuMC4w" (meaning .net 4.0). Try changing that to "j0yLjAuMC4w" (meaning .net 2.0). Worked for me. Thanks to Luis Mack at http://connect.microsoft.com/VisualStudio/feedback/details/532584/error-when-compiling-resx-file-seems-related-to-beta2-bug-5252020#


This error is presented when the compiler lost the reference of some object or when the you have changed a important property of this object, for example if you have a Grid on the form all setup (this means that you are using a DataSet as your data source to fulfill your grid), and you change the name of your DataSet VS lost this link, he will bring you this message.


i just deleted thease lines in my .RESX file

<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken="" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜