Error when compiling .resx file – Attempt to load a program with an invalid structure

I have seen this before and fixed it, but ran into it again today and could not remember what is was. When compiling a WinForms application in Visual Studio 2010, I got an error message stating “Kan bestand of assembly (…) of een van de afhankelijkheden hiervan niet laden. Poging om een programma te laden met een onjuiste indeling. ” (Roughly translated, “Can not load assembly (…) or one of its dependencies. Attempt to load a program with an invalid structure.”).

When double-clicking the error, it points to a base64-encoded piece of a resx-file, in this case an image stream for an image list.

This is a bug in Visual Studio 2010 that has not yet been fixed. See here on Microsoft Connect.

The workaround suggested by Pellet21 works for me in the mean time. I’ll copy it here to save myself from Googling for it next time:

Workaround
1.    Open Form in Designer and make needed GUI changes. Close designer and save
2.    Compile project and receive RESX compile error (only forms with Imagelist should have this problem)
3.    Double-click resx compile error to open resx file.
4.    Scroll to top of imagestream.
5.    Edit the top line of the Image stream:
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
TO
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
6.    Close and save resx file and recompile.
**NOTE: the only difference are the characters at end “j00LjAuMC4w’ to “j0yLjAuMC4w”

This needs to be done EVERY TIME you open the form in Designer mode.

Advertenties

Over Shiftkey
I am Maarten, owner of and chief software developer for Shiftkey software development from The Netherlands. I will be writing mainly about things I run into when programming in C# or Delphi.

Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s

%d bloggers liken dit: