Visual Studio创建无效的Resx文件 [英] Visual Studio creates invalid Resx files

查看:372
本文介绍了Visual Studio创建无效的Resx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的表格要本地化(我在这个项目中实际上有很多,他们都有相同的问题).当我将表单属性Localizable设置为true时,Visual Studio会生成一个具有表单名称的.resx文件(正如您所期望的那样).但是问题是,它会将所有无法打开的内容添加到.resx文件中(例如WinRes,ResEx,Simple Resx编辑器,RESX编辑器等).

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).

我得到的错误是:

ResX文件类型System.Drawing.Point,System.Drawing,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a,无法找到第125行第4位的数据. 127行,位置5.无法解析.

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.

第124行到第127行是:

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>

现在,我假设Visual Studio正在添加它,以便我可以根据语言来移动按钮等(我不需要或不需要此功能).但是,它会在除Visual Studio之外的所有其他编辑器中引发上述错误.

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:

  • 突出显示所有出现的选定单词
  • 用于WPF的Microsoft Ribbon(我在此项目中未使用)

加载项管理器没有显示加载项.

Add-in manager shows no Add-ins.

仔细研究并手动编辑.resx文件后,问题实际上出在第124行<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />上,尤其是Version=4.0.0.0.

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.

如果将其设置为Version=2.0.0.0,则在Visual Studio和所有外部程序中一切正常.但是,这样做的问题是,如果我在Visual Studio中编辑任何内容,它将把它重置回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.

暂时,我要将目标框架设置为.NET Framework 3.5客户端配置文件,以使Visual Studio不会覆盖该版本.这是一种解决方法,意味着我不能使用.NET 4.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.

我猜对了.NET Framework中是否存在错误,或者那里的每个.resx编辑器(包括Microsoft)都是正确的.

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).

修改2: 事实证明,当我尝试使用Microsoft的WinRes.exe工具时,实际上是在启动.NET Framework 3.5版本,因为未安装.NET Framework 4.0版本.

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创建正确的* .resx文件.问题是,您尝试使用的工具是为规范的先前版本创建的.这就是您的解决方法起作用的原因.

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.

这篇关于Visual Studio创建无效的Resx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆