way to force 32bit execution of .NET 2.0 in a x64 environment?

  • Thread starter Thread starter Benjamin Leak
  • Start date Start date
B

Benjamin Leak

Hello. I'm hoping for a solution to my problem, but at the same time I
suspect that I may have to go back to the development team. I am trying to
run a windows application written for a 32 bit environment on my Windows 2003
R2 SP2 x64 server. I have done a lot of research, and I know that the new
WOW is supposed to automatically determine if the application should run in
32 or 64 mode.

I have the .Net 2.0 x64 package (plus SDK) installed on this machine, but
the application crashes with a kernel32.dll error during loading. When I
ran filemon it seems that it's loading the x64 .NET framework, not the 32bit
version.

I've found a lot of information regarding forcing the application from a
code perspective, but it doesn't help me since it's not owned by my company.
I've also tried running it in xp and 2000 mode (application compat). The
vendor is not willing to support x64 environments at this time.

Any suggestions are greatly appreciated. Thank you for your time.

Ben
 
When they build the application, they should set the target platform to
"x86" rather than "any cpu". I believe if they do this, your server will
rtun it as a 32-bit application.

RobinS.
GoldMail, Inc.
 
Benjamin said:
Hello. I'm hoping for a solution to my problem, but at the same time I
suspect that I may have to go back to the development team. I am trying to
run a windows application written for a 32 bit environment on my Windows 2003
R2 SP2 x64 server. I have done a lot of research, and I know that the new
WOW is supposed to automatically determine if the application should run in
32 or 64 mode.

I have the .Net 2.0 x64 package (plus SDK) installed on this machine, but
the application crashes with a kernel32.dll error during loading. When I
ran filemon it seems that it's loading the x64 .NET framework, not the 32bit
version.

I've found a lot of information regarding forcing the application from a
code perspective, but it doesn't help me since it's not owned by my company.
I've also tried running it in xp and 2000 mode (application compat). The
vendor is not willing to support x64 environments at this time.

Any suggestions are greatly appreciated. Thank you for your time.

Ben

I had researched about this issue.

If you cannot ask the owned company to recompile the app just as RobinS
said, you can try my method. However, I just tested in very simple
application.

I assume you can make a simple dotnet app.
You need to make a very simple pure 32 bit dotnet app firstly. In the
32bit app "Main" function, using the code

/////////////////////////////////////////////////////
/*
this context is in 32bit process space
*/

string path =
System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\App64.exe";
//path finally points to the target app full path

Assembly assm64 = Assembly.LoadFile(path);
Type t=assm64.GetType("App64.Program");
/*
"App64.Program" is the class which contains the static Main() entry
point function
*/

MethodInfo mf = t.GetMethod("Main", BindingFlags.Static |
BindingFlags.NonPublic );
mf.Invoke(null, null);
////////////////////////////////////////////////////////

"App64.exe" is actually a Dotnet2 app compiled with "Any CPU"

The pure 32bit launcher app should be placed in the same folder with the
target "Any CPU" app.
 
RobinS,

Thanks! It looks like I'm going to need to put in a feature request
to the vendor, and knowing exactly what to ask should really help me in the
long run. In the mean time, I am going to try Jacky's solution.

Again, I really appreciate the reponse!

Ben
 
Benjamin said:
Hello. I'm hoping for a solution to my problem, but at the same time I
suspect that I may have to go back to the development team. I am trying to
run a windows application written for a 32 bit environment on my Windows 2003
R2 SP2 x64 server. I have done a lot of research, and I know that the new
WOW is supposed to automatically determine if the application should run in
32 or 64 mode.

I have the .Net 2.0 x64 package (plus SDK) installed on this machine, but
the application crashes with a kernel32.dll error during loading. When I
ran filemon it seems that it's loading the x64 .NET framework, not the 32bit
version.

I've found a lot of information regarding forcing the application from a
code perspective, but it doesn't help me since it's not owned by my company.
I've also tried running it in xp and 2000 mode (application compat). The
vendor is not willing to support x64 environments at this time.
You can force 32-bit execution without recompilation by using the "corflags"
utility included in the .NET SDK.
 
Back
Top