Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Forcing 32-bit CLR Exes on a 64-bit Machine

Blogs

Mike Taulty's Blog

Elsewhere

This one really comes via Mike in that today we were both running the same application on our machines ( same machine spec ) and it was working for me but not for him.

We were foxed until he pointed out that he was running 64-bit ( which I stopped running a little while ago ).

This was an EXE that was using a bunch of .NET CLR assemblies plus a bunch of unmanaged assemblies which seemed to be failing to load.

So...as we remembered from here you can't have a mixed 32-bit/64-bit process on a 64-bit machine. It has to be all one or the other.

Problem is, if you compile for CLR then generally you choose "any platform" which means Mike's EXE was choosing to JIT its code as 64-bit but then it was trying to load the unmanaged DLLs which were 32-bit and, hence, failing.

Because we didn't have the source for this code, we solved the problem by running

corflags.exe /32BIT+

on the executable which changes the header to say to the CLR "I want to JIT 32-bit code please" as though the original builder of the software had selected x86 rather than "Any CPU" in Visual Studio.

This worked a treat in this specific instance - definitely one for me to remember and so I'm storing it here.


Posted Wed, Oct 1 2008 5:06 PM by mtaulty
Filed under:

Comments

Mike Taulty's Blog wrote 64-bit, WPF, WebBrowser
on Wed, Feb 4 2009 2:30 AM

Just after I published this application , Mario mailed me and said that he liked the app but that he

Silverlight Travel » 64-bit, WPF, WebBrowser wrote Silverlight Travel » 64-bit, WPF, WebBrowser
on Wed, Feb 4 2009 6:06 AM
Silverlight Plugin Problem unter 64Bit Windows « Das nie endende Chaos! wrote Silverlight Plugin Problem unter 64Bit Windows « Das nie endende Chaos!
on Wed, Mar 11 2009 11:46 AM