Link for code samples used in the demo
Link for all dot net and sql server video tutorial playlists
In this video, we will discuss hosting a wcf service using a console application. Hosting a wcf service in any managed .net application is called as self hosting. Console applications, WPF applications, WinForms applications are all examples of managed .net applications.
Advantages of self hosting a wcf service in a console application
1. Very easy to setup. Specify the configuration in app.config file and with a few lines of code we have the service up and running.
2. Easy to debug as we don't have to attach a separate process that hosts the wcf service.
3. Supports all bindings and transport protocols.
4. Very flexible to control the lifetime of the services through the Open() and Close() methods of ServiceHost.
Disadvantages of self hosting a wcf service in a console application
1. The service is available for the clients only when the service host is running.
2. Self hosting does not support automatic message based activation that we get when hosted within IIS.
3. Custom code required.
In general, self-hosting is only suitable during the development and demonstration phase and not for hosting live wcf services.