Click here to Skip to main content
15,907,326 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Rounding Pin
Mike Dimmick20-May-08 4:52
Mike Dimmick20-May-08 4:52 
QuestionVisual Studio 2008 Pin
dotnetprg15-May-08 23:23
dotnetprg15-May-08 23:23 
AnswerRe: Visual Studio 2008 Pin
Mike Dimmick16-May-08 19:27
Mike Dimmick16-May-08 19:27 
QuestionHow to select certificate in pkcs12 file Pin
konkola15-May-08 20:31
konkola15-May-08 20:31 
QuestionHow does Windows XP know to launch the proper .Net runtime when multiple .Net framework versions get installed Pin
cateyes9914-May-08 22:32
cateyes9914-May-08 22:32 
AnswerRe: How does Windows XP know to launch the proper .Net runtime when multiple .Net framework versions get installed Pin
originSH15-May-08 0:37
originSH15-May-08 0:37 
GeneralRe: How does Windows XP know to launch the proper .Net runtime when multiple .Net framework versions get installed Pin
cateyes9915-May-08 11:29
cateyes9915-May-08 11:29 
AnswerRe: How does Windows XP know to launch the proper .Net runtime when multiple .Net framework versions get installed Pin
Mike Dimmick16-May-08 19:42
Mike Dimmick16-May-08 19:42 
Through some fun in the binary. Let's actually use Windows 2000 as the example as Windows XP knows a bit more.

An executable contains an Import Address Table which the operating system loader fills in with the addresses of all DLLs that the executable references. It does this recursively with any DLLs that those DLLs depend on. Once it's finished doing this process, it then jumps to the Start Address that's listed in the executable's header.

.NET applications have their Start Address field set to the address in the Import Address Table that the instruction to call _CorExeMain in mscoree.dll points to. So the program effectively starts up in _CorExeMain.

mscoree.dll is one of the very few components of .NET that is shared between all versions. The version present is always from the newest version of .NET installed. It implements a pretty simple policy by default: if the application was built with .NET 1.1 and .NET 1.1 is installed, .NET 1.1 is used. Otherwise, .NET 2.0 is used. What mscoree.dll actually does is load mscorwks.dll from the specified version's folder and hand the program off to that.

You can override the policy by adding a configuration file (MyApp.exe.config, if the program is MyApp.exe) and setting the <supportedRuntime> element to say which version of .NET should be used. I've used this for an unmanaged program to control the version of .NET used for COM components.

Incidentally, ".NET 3.0" is just a set of new classes. The runtime, mscorwks.dll, is not updated after .NET 2.0 (except for .NET 2.0 SP1).

It gets even more complicated for 64-bit operating systems, which are .NET-aware. Here, if the executable is compiled with /platform:x64, it gets a PE 2.0+ header indicating that a 64-bit process is required, and the 32-bit OS will reject it. If compiled with /platform:x86, it gets an original PE header indicating a 32-bit process (and a flag is set in the CLR header). However, an executable compiled with /platform:anycpu is compiled with an original PE header but runs in a 64-bit process on 64-bit Windows. I think this can only be done by the CreateProcess code recognising that it is a .NET executable and choosing to create a 64-bit process rather than a 32-bit one.


DoEvents: Generating unexpected recursion since 1991

GeneralRe: How does Windows XP know to launch the proper .Net runtime when multiple .Net framework versions get installed Pin
cateyes9916-May-08 22:59
cateyes9916-May-08 22:59 
QuestionConverting Html To Word file Pin
Shivarudrayya H14-May-08 19:06
Shivarudrayya H14-May-08 19:06 
QuestionHow to have an always running app on wm5 Pin
astabile14-May-08 5:33
astabile14-May-08 5:33 
AnswerRe: How to have an always running app on wm5 Pin
Dave Kreskowiak14-May-08 7:24
mveDave Kreskowiak14-May-08 7:24 
Questionwab and .net Pin
ERLN13-May-08 19:45
ERLN13-May-08 19:45 
AnswerRe: wab and .net Pin
Dave Kreskowiak14-May-08 7:22
mveDave Kreskowiak14-May-08 7:22 
QuestionCan't set reference to dll built on another machine Pin
Bob West13-May-08 4:20
Bob West13-May-08 4:20 
AnswerRe: Can't set reference to dll built on another machine Pin
led mike13-May-08 4:48
led mike13-May-08 4:48 
GeneralRe: Can't set reference to dll built on another machine Pin
Bob West13-May-08 7:12
Bob West13-May-08 7:12 
AnswerRe: Can't set reference to dll built on another machine Pin
Peter Josefsson Sweden16-May-08 23:29
Peter Josefsson Sweden16-May-08 23:29 
QuestionLocalizing a text file Pin
Ponzano Paolo13-May-08 3:17
Ponzano Paolo13-May-08 3:17 
QuestionDisassembling a GAC-installed assembly Pin
ctoma200513-May-08 3:01
ctoma200513-May-08 3:01 
AnswerRe: Disassembling a GAC-installed assembly Pin
Mark Churchill18-May-08 4:12
Mark Churchill18-May-08 4:12 
QuestionWhich version of Visual Studio 2008 has to be installed? Pin
meeram39512-May-08 18:59
meeram39512-May-08 18:59 
AnswerRe: Which version of Visual Studio 2008 has to be installed? Pin
Christian Graus12-May-08 19:10
protectorChristian Graus12-May-08 19:10 
QuestionURL not opening Pin
Montu7612-May-08 18:00
Montu7612-May-08 18:00 
AnswerRe: URL not opening Pin
SomeGuyThatIsMe13-May-08 3:15
SomeGuyThatIsMe13-May-08 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.