tags:

views:

137

answers:

2

Consider we have .NET Winforms application or Console Application. Can anyone tell me what will happen step-by-step until the WinForm or Console Application is launched. I would like know the internals - like how EXE will communicate with Framework, what is the role of CLR, what happens in case of exception while launching applicaiton itself.etc...

A: 

You probably wants something like: Microsoft .NET Internals

http://www.amazon.com/Microsoft-NET-Internals-Tom-Christian/dp/0735626758/ref=sr_1_1?ie=UTF8&s=books&qid=1273233479&sr=1-1

Or since that's not released yet: Essential .NET, Volume I: The Common Language Runtime

http://www.amazon.co.uk/Essential-NET-Microsoft-Development-Paperback/dp/0201734117

ho1
Thank you ho. I ll check through the books
Sathish
+7  A: 

When you double click on a .net .exe assembly:

  • Windows' PE loader kicks in
  • If you're on a Windows >= Windows XP it will detect that the executable is a managed executable and will forward it to .net by calling _CoreExeMain in mscoree.dll (_CoreDllMain if you double clicked on a managed .dll). It can use the assembly configuration file to know which runtime to use.
  • If you're on Windows < Windows XP, the .exe file contains a small native piece of code that will jump to mscoree.dll's _CoreExeMain or _CoreDllMain.
  • Then mscoree.dll initializes the .net runtime, depending on the global configuration, the assembly configuration file, and what not.
  • Then if it's a .exe, it will JIT compile its entry point method, and start executing it.
Jb Evain
This is great. Thank for your answer Jb Evain!
Sathish