May 2 2009

Using 32-bit .Net Applications on a 64-bit system

I needed to use the Windows Mobile Security Power Toy the other day.  So I download the power toy, fired it up, and watched it promptly crash. After several failed attempts I figured there was soemthign wrong with my computer, so I went to another computer and did the same thing with success.  In trying to diagnose the problem I went to another computer and tried to run the power toy and it crashed there also.  So what was the problem?

In looking at the similarities and differences among the computers I realized that the two computers on which the application crashed had one thing in common - they were 64-bit machines whereas the machine on which the power toy worked was a 32-bit machine.  I ran into a problem like this years ago.  I had a .Net application that P/Invoked some 32-bit APIs.  The computer would automatically load the .Net code in a 64-bit process, but 64-bit and 32-bit code cannot coexists in the same process which is why the program would crash.  When I ran into this problem years ago I just changed the settings on my project so that the code would NGEN to 32-bit code (that means it was converted to x86 code at compile time).  But I don't have the source code for the Windows Mobile Security Power Toy.  So what could I do?

There's a command line utility that would help me here. It allows one to start a .Net executable and load it into a 32-bit process. the utility is named CORFLAGS.EXE.  I went back to the 64-bit machines, opened the command prompt, and typed the following:

COREFLAGS.EXE SecurityManager.exe /32BIT+

Success!

Tags:

Comments

1.
trackback J2i.Net says:

Windows Phone Deployment Patterns Part 1 of n

Windows Phone Deployment Patterns Part 1 of n