all groups > dotnet clr > december 2006 >
You're in the

dotnet clr

group:

How do OS loads CLR


How do OS loads CLR Deepabh
12/12/2006 1:57:31 AM
dotnet clr:
Hi.
I want to know how do OS differentiate an exe created by Visual Studio
6.0 or Visual Studio .Net ?? And if multipule versions of CLR are
there, how do it loads the required version.

Thanks in adv
Deepabh
Re: How do OS loads CLR Ben Voigt
12/12/2006 12:38:31 PM

[quoted text, click to view]

Why would the OS need to differentiate? I think that XP does, but managed
exes also work on earlier versions of Windows.

The native linker/loader reads the process into memory, enumerates the
static-dependencies and starts doing LoadLibrary on each one, which causes
the DllMain to run... long before any code in the .exe runs. Managed exes
have a static dependency on the CLR runtime DLL. This gives the CLR a
chance to compile the process entry point.

If you want to recognize a managed application, look for a dependency on
mscoree.dll

[quoted text, click to view]

Re: How do OS loads CLR William DePalo [MVP VC++]
12/12/2006 3:50:09 PM
[quoted text, click to view]

I'm not sure that I understand the gist of your question.

I can tell you that recently VS2003 failed to debug managed components
loaded by the CLR which was itself loaded by a native application of mine,
after being able to debug those components for months.

It turns out that the failure was caused because VS2003

a) can only debug managed applications using v1.1 of the framework

and

b) by default, it loads the most recent version of the framework

Item b bit me because I had recently installed v3 of the framework. Catch
22.

The workaround is described here:

http://blogs.msdn.com/jmstall/archive/2005/12/05/VS2003_crashes_with_2005.aspx

Does that help?

Regards,
Will


Re: How do OS loads CLR Gabriel Lozano-Morán
12/12/2006 11:29:08 PM
As far as I know the CLR version for which it was build for will be loaded
and if that version is not installed than the
<requiredRuntime>/<supportedRuntime> elements in the application's
configuration file would determine which version of the CLR to load and if
this element is not set in the config the most recent version of the CLR
will be loaded.

The documentation on the MSDN Library is contradictory but by analyzing the
CLR Load Logging you will get a clearer view of which CLR version will be
loaded and why:
http://pointerx.net/blogs/glozano/archive/2006/03/24/84.aspx

Furthermore it is possible to set a default version of the CLR to load
machine-wide (which is not recommended and it propably only exists for
debuggin purposes):
http://pointerx.net/blogs/glozano/archive/2006/03/26/106.aspx

Gabriel Lozano-Morán
The .NET Aficionado
http://www.pointerx.net

[quoted text, click to view]

Re: How do OS loads CLR Gabriel Lozano-Morán
12/12/2006 11:48:39 PM
About your first question, after installing .NET Framework, opening managed
applications will be cause MSCoree.exe to be loaded in the process.
MSCoree.exe is located in the System folder but that depends if you are
running the 32-bit or the 64-bit Windows platform. In MSCoree it is
determined which CLR version to load and loads it and then loads the
assembly.

It is almost like double-clicking a .wmv file and having the system launch
Windows Media Player. Off course this example is oversimplified but it is
just to get the idea.

Gabriel Lozano-Morán
The .NET Aficionado
http://www.pointerx.net

[quoted text, click to view]

Re: How do OS loads CLR tdeepabh NO[at]SPAM gmail.com
12/13/2006 2:19:00 AM
[quoted text, click to view]

I looked at task manager after double clicking a test.exe created in VS
..Net 2003, i could not find MSCoree.exe. Should it be there ?
How different is PE/COFF of VS C++ and VS .Net ? Does it contain any
info about CLR version ?=20

Regards,
Deepabh
Re: How do OS loads CLR Phill W.
12/13/2006 11:42:39 AM
[quoted text, click to view]

You can, so long as you've replaced "Task Manager" (in the Start Bar
context menu) with SysInternals' Process Explorer. ;-)

Regards,
Re: How do OS loads CLR Willy Denoyette [MVP]
12/13/2006 12:19:43 PM
[quoted text, click to view]

I looked at task manager after double clicking a test.exe created in VS
..Net 2003, i could not find MSCoree.exe. Should it be there ?
How different is PE/COFF of VS C++ and VS .Net ? Does it contain any
info about CLR version ?

Regards,
Deepabh


mscoree.dll not mscoree.exe.
You can't see what dll's are loaded in a process using taskman.

Willy.




Re: How do OS loads CLR Willy Denoyette [MVP]
12/13/2006 3:56:14 PM
[quoted text, click to view]


Yep, but then you don't run "Taskman" but "process explorer".

Willy.
Re: How do OS loads CLR Gabriel Lozano-Morán
12/13/2006 6:20:50 PM
[quoted text, click to view]

Microsoft extended the PE header to add additional information, you can see
the difference using a PE exploring tool of some kind.

Gabriel Lozano-Morán
The .NET Aficionado
http://www.pointerx.net

[quoted text, click to view]

I looked at task manager after double clicking a test.exe created in VS
..Net 2003, i could not find MSCoree.exe. Should it be there ?
How different is PE/COFF of VS C++ and VS .Net ? Does it contain any
info about CLR version ?

Regards,
Deepabh

AddThis Social Bookmark Button