Cook Computing

Contract Name Not Found In List Of Contracts

September 1, 2007 Written by Charles Cook

I have just started to dive into Windows Communication Foundation. Long overdue I know. One beginner's tip is that if an instance of InvalidOperationException is thrown when you try to create your service host and the exception's message is something like this:

The contract name 'TestContract' could not be found in the list of contracts implemented by the service 'TestService'.

... it may be because you have forgotten to specify that the interface is a service contract. You need to decorate the interface with the ServiceContract attribute:

public interface TestContract
  int Add(int x, int y);