How to make this sample work:
1. Create a Console Application project. There is actually a "WCF Service Application" project type in Visual Studio 2008 - do not use it for this example. Remove Program.cs from the project.
2. Add references to System.Configuration.Install, System.ServiceModel and System.ServiceProcess.
3. App.config is missing a closing tag:
</system.ServiceModel>
4. In App.config, ensure that the service name and the endpoint contract for wsHttpBinding reflects the namespace that you're using. The given App.config assumes that the namespace is Microsoft.ServiceModel.Samples. If, for instance, the ICalculator interface and the CalculatorService class are in the namespace Joe.Samples, your App.config should be as follows:
...
<system.serviceModel>
<services>
<service name="Joe.Samples.CalculatorService">
...
<endpoint address=""
binding="wsHttpBinding"
contract="Joe.Samples.ICalculator" />
5. As pointed out by DWDragen, the behaviors section in App.config is missing:
...
<system.serviceModel>
<services>
<service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
...
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Note that you need to add the behaviorConfiguration attribute.
6. The CalculatorService() method is supposed to be a constructor (but this is not a showstopper):
public void CalculatorService()
{
ServiceName = "WCFWindowsServiceSample";
}
should be
public CalculatorWindowsService()
{
ServiceName = "WCFWindowsServiceSample";
}