What is the exactly Runtime Host?

2019-05-08 07:45发布

问题:

What is the exactly definition of Runtime Host?

From MSDN:

The common language runtime has been designed to support a variety of different types of applications, from Web server applications to applications with a traditional rich Windows user interface. Each type of application requires a runtime host to start it. The runtime host loads the runtime into a process, creates the application domains within the process, and loads user code into the application domains.

So is it a process which loads the runtime into another process?
How do I check it in Task Manager?

回答1:

No, it's a process that loads the runtime DLLs ( e.g. mscoree.dll, etc ) into its process space.

So there is only 1 process space.

The runtime that is referred to is really the .Net runtime or CLR. And from a simplified traditional OS point of view, the CLR is really just a set of DLLs. So, you need a OS process to load and execute the entry point of that DLL. This hosting executable is your runtime host. In reality the .Net runtime host does a lot of things for the CLR ( See Hosting Overview )

You mentioned MSDN, so I guess you've looked at Runtime Hosts on there. You can see the examples they give are all executables that host the CLR ( DLLs ).

Hope that helps.



回答2:

This article might help: Implementing a custom runtime host. It discusses the various aspects of the host and when/why you might want to implement your own.

Lifted directly from the article:
examples of hosts that ship with the .NET Framework include:

  • ASP.NET: An ISAPI filter that ships with ASP.NET is responsible for starting the CLR and initializing the plumbing needed to route Web requests to the ASP.NET processes.
  • Internet Explorer: The .NET Framework ships with a MIME filter that hooks into Internet Explorer 5.01 or later to execute managed code controls that are referenced from HTML pages.
  • Shell Executables: Each time an executable is launched from the shell, a small piece of unmanaged code gets invoked that transitions control to the CLR.

Other hosts could include:

  • Database Engines A future version of Microsoft SQL Server will allow stored procedures to be written in languages that support the .NET Framework and are executed with the CLR.
  • Personal Organizers Several e-mail/calendar/contact programs allow users to write scripts to customize the processing of e-mail messages, appointments, and so on. It's easy to imagine these scripts running on the CLR. The security system provided by the CLR is especially important in this scenario because of the proliferation of viruses spread by e-mail systems.