How does a .net executable run..?Posted: August 14, 2009
Have you ever wondered how a .net program runs..? Does it starts as a native program or as a managed image..? Many would have thought that a .net code runs in a speical managed user space. But in reality, when u instantiate a .net executable, from shell or command prompt, it does start as a native code. Here is how the process works.
The managed code cannot run directly as the Operating System itself is native code. So when you run a .net executable, lets say from comman prompt you invoked it, the command shell, calls the mscorree.dll(native code) methods to first load the .net runtime. Then within that run time it calls the managed executable. Now the managed code runs within the .net run time.
The above process is similar when it comes to ASP.net page cycle. When u request a asp.net page, the IIS invokes the ASP.net runtime host (again native code) which load the asp.net runtime which then runs the asp.net page to generate the html output.
If you closely observe the above processes you can see that most of the process involves running native code. Damn, the CLR itself is unmanaged code.We can mimic the same process of running a managed executable but calling mscorree.dll methods from within Unmanaged code. I will post the code shortly, as I dont have C++ or VB 6.0 environment.