6

这是我最近遇到的一个故事和一个可能的答案(?)我只是想分享这些信息,因为我在 stackoverflow 上还找不到。

我将我的解决方案从 VS2008、WinXP、32 位升级到 VS2010、Win7、64 位。

当我对生成新 RESX 文件或更新 RESX 文件的 WinForms 进行修改时,我遇到了问题。

使用 VS2010 进行调试构建没有问题。但是对于发布模式,我必须使用延迟签名过程。现在,该过程在使用 VS2010 生成的RESX 文件上出现错误。(再次注意旧的 RESX 文件不显示此行为)

(CoreResGen 目标)Search.resx(176,5):错误 RG0000:无法加载文件或程序集 xxx.Controls,版本 = 1.5 0,文化 = 中性,PublicKeyToken = 7acfcc7eabace048' 或其依赖项之一。强名称验证失败。(HRESULT 除外:0x8013141A)第 176 行,位置 5。

这是我在网上找到的一些信息

http://blogs.msdn.com/b/visualstudio/archive/2010/06/19/resgen-exe-error-an-attempt-was-made-to-load-a-program-with-an-incorrect-格式.aspx

我想知道其他人是否遇到了这个问题以及他们遵循了哪种解决方法?没有解决方法意味着,等待 VS2010 SP1 出来。

不幸的是,我正在使用可能已编译为 32 位的第 3 方程序集。(我无法控制他们的构建过程)

-- 2010 年 8 月 11 日 一些附加信息。

控件本身没有签名或延迟签名。但是控件正在使用延迟签名的程序集中的组件。两个程序集都在同一个解决方案中。

当我将消费程序集更改为针对 4.0 框架时,问题就解决了。当我针对 3.5 框架时,我们得到了错误。

4

1 回答 1

1

The issue we experienced was also with the ImageList inside the *.resx file (opened in code, not the designer):

<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
        [bunch of binary data here]
    </value>
</data>

We confirmed this was by only deleting the <data /> tag related to the ImageList (see above) and then deleting the references in the control's designer:

//initialize
this.imageListSuperHeroes = new System.Windows.Forms.ImageList(this.components);

//control that references the ImageList
this.btnAwesome.ImageKey = "superman.gif";
this.btnAwesome.ImageList = this.imageListSuperHeroes;

Add the image references (use individual images!) of the control from the "Project resource file", rather than the "Local resource" and update the references you removed from your forms.

this.btnAwesome.Image = global::PMPPlus.Properties.Resources.Superman;

That fixed it for us and hopefully this helps move you in the right direction. If not, dig around the *.resx to see which bad <data /> is screwing you up.

Related link: http://connect.microsoft.com/VisualStudio/feedback/details/566131/error-in-resx-file-when-adding-imagelist

They suggested some workarounds that didn't fit our needs:

  • Target another platform and framework
  • Use corflags to screw with your C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bin directory!

Our Setup

  • Old Environment: Windows XP 32-bit
  • New Environment: Windows 7 64-bit
  • Common Setup: VS2010 + Target Framework: 3.5 + Target Platform: x86
于 2011-09-01T13:23:38.617 回答