tags:

views:

317

answers:

2

On a 32 bit Windows Server 2003 machine I have created a Visual Studio Class Library project and platform target configured to "Any CPU". The project has reference of System.Data.

I changed the platform target to x64, built the project and put the DLL in GAC on a 64 bit machine. The 64 bit machine has both 64 bit and 32 bit versions of System.Data.

In this case, my DLL referes to which System.Data - 32 bit or 64 bit?

Thanks in advance!

Update: I can see my DLL running in AMD64 bit mode on the 64 bit machine.

+1  A: 

If you target "x64" then your program references the 64-bit version of System.Data.

jcopenha
+1  A: 

When you compile in "Any CPU" configuration, then your program will run on either x86 or x64 (and, perhaps, on other architectures, though I dont know of any other implementation of the .NET framework that run on other architectures, but this is offtopic).

If you compile in x86 configuration, then your app will run ONLY on x86 machines (though, win x64 can run x86 apps, and thus your app WILL run on it, though it will still be an x86 app). Similarly, if you compile with the x64 configuration, you app will run ONLY on x64 machines, and not on x86 machines.

As a result, when your app runs on a x86 machine, it uses 32 bit dll. And when it runs on an x64 machine, it will use he 64 bit dll, assuming you compiled in x64 or "Any CPU"; if you compiled as "x86", it will use the 32 bit dll.

I hope that wasn't too confusing.

AASoft
So, on x64 machine, my project DLL compiled in x64 will use x64 `System.Data` DLL. Is that correct?
Vijay
Yes, that is correct.
AASoft