Exploring Your Hosting Options

On the Microsoft .NET platform, you have several types of managed Windows applications that you can create with Visual Studio .NET:

  • WinForms applications

  • Console applications

  • Windows services

  • Web applications (ASP.NET) hosted on Internet Information Services (IIS)

  • WCF services inside IIS 7.0 and WAS on Windows Vista or Windows Server 2007

If you look through the project templates that come with Visual Studio 2005, you will find other options available at your disposal. For obvious reasons, we don't consider any of the other templates to be viable options to use in the services world. It is worth noting, however, that WCF doesn't block you from running your service in any other type of application as long as it provides you with a .NET application domain. If you don't know the concepts behind a .NET application domain, please refer to the "Understanding .NET Application Domains" sidebar. It all comes down to the requirements you have for your host. To summarize the options, think about the following three generic categories of hosts for your WCF services:

  • Self-hosting in any managed .NET application

  • Hosting in a Windows service

  • Hosting in different versions of IIS

As you can imagine, all these have associated project templates in Visual Studio, as mentioned earlier in this section, and all of them have their own characteristics. To get a better understanding of which host is the best in each situation, you need to understand the requirements and the features hosts typically have. After you understand this, we will walk you through each hosting option individually.

UNDERSTANDING .NET APPLICATION DOMAINS

Assuming you understand the role of Windows processes and how to interact with them from managed code, you need to investigate the concept of a .NET application domain. To run your managed .NET code in a process, you create assemblies. These assemblies are not hosted directly within a Windows process. Instead, the common language runtime (CLR) isolates this managed code by creating separate logical partitions within a process called an application domain. A single process may contain multiple application domains, each of which is hosting distinct pieces of code encapsulated in assemblies. This subdivision of a traditional Windows process offers several benefits provided by the .NET Framework.

The main benefits are as follows:

  • Application domains provide the operating system-neutral nature of the .NET platform by abstracting away the concept of an executable or library.

  • Application domains can be controlled and (un)loaded as you want.

  • Application domains provide isolation for an application or within a process where multiple application domains live. Application domains within a process are independent of each other and as such remain functional when one fails the other.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset