Building a WCF Service

Building a WCF service is not hard to accomplish. Using Visual Studio 2012, you'll see the WCF new project templates shown in Figure 11.2. One word of warning, however—in order to host a WCF service you'll need Administrator rights. Before attempting to replicate all of the steps in the sample, make sure you've started Visual Studio using the ‘Run as Administrator' option from the context menu.

Figure 11.2 New WCF project templates


When you build a WCF project in this manner, the idea is that you build a traditional class library that is compiled down to a DLL that can then be added to another project. The separation of code and use of multiple projects is a powerful tool for managing complexity on larger projects. That said, though, you can also just as easily build a WCF service directly in your .NET project, whether that is a console application or a Windows Forms application.

This example will first create a new WCF service in a Service Library. It then demonstrates how to host the WCF service inside a console application. Start by creating a new Service Library with the name ProVB_WCFCalculatorLibrary.

Once you have created your new library project, Visual Studio will look similar to what is shown in Figure 11.3.

Figure 11.3 WCF project template interface definition

This example first demonstrates how to build the WCF service. It then demonstrates ...

Get Professional Visual Basic 2012 and .NET 4.5 Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.