Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Availability of 32-bit .NET on a 64-bit OS

Tags:

.net

TLDR: When installing .NET on a 64-bit OS, are the 32-bit components always present?

I used to have my app (IronScheme) compiled entirely as AnyCPU. While this works great for all platforms, the 64-bit JIT compiler just seems too slow for my liking (about 550% slower startup and about 25% slower in general). The startup slowness can be solved by NGEN'ng my assemblies and does in fact improve startup time another odd 500% when done so. This is gives about a 2600% improvement on startup time (3700ms vs 140ms) on 64-bit. When both 32-bit and 64-bit are NGEN'd, the startup times are the same, but 32-bit still performs better at runtime.

Now given in most cases 64-bit is not needed at all, I think targeting x86 in the executable would just be the best general solution (all the other assemblies are targeting AnyCPU, but from what I can see, the executable determines where it goes). So the idea is to to have 2 startup executables, one targeting x86, the other x64 (or amd64 as MS calls it).

When installing on a 32-bit OS, I can be sure no 64-bit components are present. But what about the opposite case? Does the .NET installer install both 32-bit and 64-bit components? This is important as NGEN'ng a non-AnyCPU assembly will fail if the target does not match the runtime.

Example:

"Error compiling IronScheme.Console.exe: This version of is not compatible with the version of Windows you're running."

Also note that my application is built by default for .NET 2 and in VS2008, so the new AnyCPU (32-bit preferred) option (in VS2012/.NET 4.5) is not an option for me at this time.

PS: Sorry, if this has been asked before. I have no idea how to search for this specific issue, and my Google fu failed me too.

like image 849
leppie Avatar asked Aug 04 '12 19:08

leppie


People also ask

Can I run Windows 32-bit on a 64-bit computer?

Both a 32 and 64 bit OS can run on a 64 bit processor, but the 64 bit OS can use full-power of the 64bit processor (larger registers, more instructions) - in short it can do more work in same time. A 32 bit processor supports only 32 bit Windows OS. This is incorrect generally, though correct for x64 specifically.

Can Windows XP 32-bit run on a 64-bit computer?

Yep, you can run 32-bit x86 Windows on an x64 machine. Note that you can't do this on Itanium 64-bit systems. Certainly is. You cannot install 64 bit operating systems on 32 bit systems, but you can most definitely install 32 bit operating systems onto 64 bit systems.

Can 64-bit applications contain 32-bit code?

64 bit CPU can run both 32 bit and 64 bit operating systems and applications. If 32 bit OS is run, the whole system acts as purely 32 bit, including memory address space limitations. It is not possible to use any 64 bit piece of code, 64 bit applications do not work.


1 Answers

are the 32-bit components always present on a 64-bit OS?

No. But the case that it isn't installed is somewhat rare. Windows Server Core 2008 R2 (and presumably Core 2012) support WOW64 as a separate, installable, and removable component - including the .NET bits. Take a look here for a little more information.

In order to install the WOW64 components for Server Core 2008 R2 this needs to be run:

Start /w ocsetup NetFx3-ServerCore-WOW64

Server Core is the only case I have been able to find where the x64 components may be available, but the x86 ones may not be. If you are not targeting or supporting Server Core, then I believe it is safe to assume the x86 bits will be there along side with the x64 bits.

like image 154
vcsjones Avatar answered Nov 15 '22 07:11

vcsjones