From: amdrit on
We are having an issue on one Citrix box in the farm. When the application
attempts to load one of our ocx's an exception is thrown "An attempt was
made to load a program with an incorrect format."

The ocx is a wrapper for a .Net dll that houses a webbrower control. The
support technicians at that site say that the issue became apparent about
two weeks ago and nothing has changed on the box since before December of
09. This is also true of the other machines on the farm, though they all
work as expected.

When googling the issue, everyone is convinced that such errors are related
to running x86 binaries on x64 platforms. This machine is and always has
been a single x86 xeon processor with 4GB RAM running Win'03 sp2. So I am
confident that this is not a compilatiion issue. I am still perplexed as to
where to begin in diagnosing this issue.

The KB article: http://support.microsoft.com/kb/137248 suggests that there
are other reasons for this issue to occur. I am no closer to identifying
the problem, nor am I able to replicate this issue. Unfortunately this is a
production machine so I am unable to do too much with the box to set up a
test lab. I have written a test harness in both VB6 and in C#. The VB6 exe
represents the endpoint call through the ocx to the C# dll. The C# exe
represents a native call to the C# dll directly. Naturally, the issue is
with the C# dll. The error being thrown there is:

System.BadImageFormatException: Could not load file or assembly '0 bytes
loaded from System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was
made to load a program with an incorrect format.
File name: '0 bytes loaded from System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' ---> System.BadImageFormatException: Bad IL
format.

Running Peverify against the dll and the two dependancies, everything
reports fine.

Anyone have any suggestions as where I should look next?