How do exes/dlls generated with the /platform:x switch interact?
[fixed typo: 9:37am]
I received a question about this recently, so i figured i'd elaborate here with a little example...
Let's assume we have the following three dlls:
anycpu.dll -- compiled "any cpu"
x86.dll -- compiled "x86"
x64.dll -- compiled "x64"
And the following three exes:
anycpu.exe -- compiled "any cpu"
x86.exe -- compiled "x86"
x64.exe -- compiled "x64"
What happens if you try to use these exes and dlls together? We have to consider two possible scenarios, running on a 32-bit machine and running on a 64-bit machine...
On a 32-bit x86 machine:
anycpu.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll
x86.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll
x64.exe -- will get BadImageFormatException when it tries to run
On a 64-bit x64 machine:
anycpu.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll
x86.exe -- runs as a 32-bit process, can load anycpu.dll and x86.dll, will get BadImageFormatException if it tries to load x64.dll
x64.exe -- runs as a 64-bit process, can load anycpu.dll and x64.dll, will get BadImageFormatException if it tries to load x86.dll
Comments
Anonymous
April 08, 2005
Surely you mean x86.exe on 64-bit will get a BIFE when it tries to load x64.dll, rather than x86.dll?Anonymous
April 08, 2005
Yep! Typo fixed, thanks for the catch.Anonymous
April 26, 2005
Is there a difference if compiling with VS.NET 2005 Standard vs. Professional?
The comparison card says that Standard does not support a 64-bit compiler. So what would happen if you select anyCpu using the Standard edition?Anonymous
April 26, 2005
One more bit of info regarding my last query: We're using C# if that makes any difference.
Regards.Anonymous
April 29, 2005
Steve --
I'm in the process of writing up a blog entry to address your questions and the more general case of "what does it take to compile for 64-bit". I will probably post it early next week.
-joshAnonymous
May 06, 2005
In a number of blog entries I have discussed how on 64-bit machines .Net applications can run as either...Anonymous
May 20, 2007
PingBack from http://millicentboh.wordpress.com/2007/05/21/flipping-bits-on-managed-images-to-make-them-load-with-the-right-bitness/Anonymous
January 04, 2008
PingBack from http://famousquotes.247blogging.info/?p=320Anonymous
March 08, 2008
PingBack from http://vivekwin.wordpress.com/2008/03/08/function-arguments/Anonymous
September 25, 2008
PingBack from http://www.dukhsukh.com/2008/09/aspnet-interview-questions-with-answersframeworkbasic-and-advance/Anonymous
March 15, 2009
PingBack from http://praveenkhade.wordpress.com/2009/03/16/c-sharp-faqs/