Issues with RESX files on VS2010 targeting 3.5 framework

6

Here is a story what I recently ran into and a possible answer(?) I just wanted to share this information because I could not find this yet at stackoverflow.

I upgraded my solution from VS2008, WinXP, 32bit TO VS2010, Win7, 64bit.

When I make modifications on WinForms that generate new RESX files, or update the RESX files, I'm running into problems.

A Debug build with VS2010 was no problem. However for Release mode I have to use a delay-signing process. Now that process gives errors on new RESX files that are generated with VS2010. (Again note that old RESX files do NOT show this behaviour)

(CoreResGen target) Search.resx(176,5): error RG0000: Could not load file or assembly xxx.Controls, Version=1.5 0, Culture=neutral, PublicKeyToken=7acfcc7eabace048' or one of its dependencies. Strong name validation failed. (Exce on from HRESULT: 0x8013141A) Line 176, position 5.

Here is some of the information I found on the web

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

I was wondering if other peopele ran into this and which workaround they followed? No workaround would mean, waiting for the VS2010 SP1 to come out.

Unfortunately I'm using 3rd party assemblies that might have been compiled as 32bit. (I'm not in control of their build process)

-- 8/11/2010 Some additional information.

The control itself is not signed or delay-signed. But the control is using a component from an assembly that is delay-signed. Both assemblies are in the same solution.

When I change the consuming assembly to target the 4.0 framework the issue is resolved. When I target the 3.5 framework, we get the error.

visual-studio-2010
msbuild
resx
windows-7-x64
asked on Stack Overflow Aug 3, 2010 by Sentient • edited Aug 11, 2010 by Sentient

1 Answer

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
answered on Stack Overflow Sep 1, 2011 by omgtitb

User contributions licensed under CC BY-SA 3.0