Hosting a service in a console application
When creating a simple demo program for .NET framework, we will probably choose a console application. At the same, when talking about WCF service hosting, the console-hosting scenario is the most convenient one, which is especially handy and useful when we want to do some quick demo or testing on some WCF functionality.
How to do it...
Create a .NET framework-based Console project through Visual Studio.
Visual Studio provides various project templates for creating a .NET framework-based application. For our sample console-hosting service here, we will choose the Console Application project type from the Visual Studio New Project wizard.
Add a new WCF service into the project.
We can simply accomplish this by using the Add New Item function in Visual Studio and choose WCF Service as the item type from Visual Studio's Add New Item UI.
Add code into the
Main
function to start up the WCF service. The following code shows the typicalMain
function that...