none
how the double click a .exe launches the application RRS feed

  • Question

  • What happens when a .net based windows application  (output of .net windows form application) starts running...

    I mean when i double click a .exe how the application get launched ..what the involvement of windows and how the app domain gets created and when the CLR come into picture...how the process is getting created for the windows application and how the heap is  created..
    i want to know the order of the above process..

     


    ilikemicrosoft

    Thursday, May 23, 2013 6:21 AM

Answers

  • Every executable embeds a PE32 header. This header contains the address of entry point method inside the executable (usually Main method). So, when you double click the executable, Operating System reads the address of entry point method and begins executing from that point.

    In case of .NET executable, the entry point is always the _CorExeMain method present inside MSCOREE.DLL. This _CorExeMain method reads the CLR header present in the executable and loads the correct .NET Framework, sets-up execution environment and jumps to entry point of your executable (mentioned in CLR Header). And at this point, the execution of your assembly begins.

    For more info, visit below pages,

    http://msdn.microsoft.com/en-us/magazine/cc301479.aspx

    http://msdn.microsoft.com/en-us/magazine/cc301805.aspx
    http://msdn.microsoft.com/en-us/magazine/cc301808.aspx

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Thursday, May 23, 2013 8:50 AM

All replies

  • What happens when a .net based windows application  (output of .net windows form application) starts running...

    I mean when i double click a .exe how the application get launched ..what the involvement of windows and how the app domain gets created and when the CLR come into picture...how the process is getting created for the windows application and how the heap is  created..
    i want to know the order of the above process..


    ilikemicrosoft

    Thursday, May 23, 2013 8:27 AM
  • Every executable embeds a PE32 header. This header contains the address of entry point method inside the executable (usually Main method). So, when you double click the executable, Operating System reads the address of entry point method and begins executing from that point.

    In case of .NET executable, the entry point is always the _CorExeMain method present inside MSCOREE.DLL. This _CorExeMain method reads the CLR header present in the executable and loads the correct .NET Framework, sets-up execution environment and jumps to entry point of your executable (mentioned in CLR Header). And at this point, the execution of your assembly begins.

    For more info, visit below pages,

    http://msdn.microsoft.com/en-us/magazine/cc301479.aspx

    http://msdn.microsoft.com/en-us/magazine/cc301805.aspx
    http://msdn.microsoft.com/en-us/magazine/cc301808.aspx

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Thursday, May 23, 2013 8:50 AM
  • duplicate - http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/69b30f61-e979-4f31-b090-708d8441965d

    Please mark this post as answer if it solved your problem. Happy Programming!

    Thursday, May 23, 2013 10:25 AM
  • the explanation is not that clear..Could you please explain that in simple terms...the order of what happens one after another

    ilikemicrosoft

    Friday, May 24, 2013 10:20 AM
  • Hi,

    All .Net Assemblies contain a PE Header file which has the information like whether it requires 32 or 64 bit OS,from which version of .Net it was built and also the desired CPU architecture where it can run.

    When we double click a .exe file, windows will first read this file and gets to know what Address space is required,whether 32 or 64 bit.Also it checks whether CPU architecture is met.

    After all these checks, windows will load the appropriate version of MScoreEE.dll (32 or 64 bit) into the process address space.The main method in MScoreEE.dll  always loads and initialises the CLR and then our Entry Point i.e. Main is called.
    Thus  .Exe starts running.

    Hope you find this useful.
    Saturday, May 25, 2013 2:29 PM