Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / December 2006

Tip: Looking for answers? Try searching our database.

How do OS loads CLR

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Deepabh - 12 Dec 2006 09:57 GMT
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
Ben Voigt - 12 Dec 2006 18:38 GMT
> 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.

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

> Thanks in adv
> Deepabh
William DePalo [MVP VC++] - 12 Dec 2006 20:50 GMT
> 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.

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
Gabriel Lozano-Morán - 12 Dec 2006 22:29 GMT
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

> Hi.
> I want to know how do OS differentiate an exe created by Visual Studio
[quoted text clipped - 3 lines]
> Thanks in adv
> Deepabh
Gabriel Lozano-Morán - 12 Dec 2006 22:48 GMT
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

> Hi.
> I want to know how do OS differentiate an exe created by Visual Studio
[quoted text clipped - 3 lines]
> Thanks in adv
> Deepabh
tdeepabh@gmail.com - 13 Dec 2006 10:19 GMT
> 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.

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
Willy Denoyette [MVP] - 13 Dec 2006 11:19 GMT
Gabriel Lozano-Morán wrote:
> 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.

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.
Phill W. - 13 Dec 2006 11:42 GMT
> You can't see what dll's are loaded in a process using taskman.

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

Regards,
   Phill  W.
Willy Denoyette [MVP] - 13 Dec 2006 14:56 GMT
>> You can't see what dll's are loaded in a process using taskman.
>
[quoted text clipped - 3 lines]
> Regards,
>    Phill  W.

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

Willy.
Gabriel Lozano-Morán - 13 Dec 2006 17:20 GMT
>How different is  PE/COFF  of VS C++ and VS .Net ? Does it contain any info
>about CLR version ?

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

Gabriel Lozano-Morán wrote:
> About your first question, after installing .NET Framework, opening
> managed
[quoted text clipped - 3 lines]
> determined which CLR version to load and loads it and then loads the
> assembly.

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.