The contract name \'IMyService\' could not be found in the list of contracts implemented by the service \'MyService\'.. ---> System.InvalidOperationException: The
I had the same error but the source of the problem was different. I was learning as I going and I first created a service using the Silverlight-enabled WCF service from the Silverlight templates in Visual Studio. I called this TerritoryService. When you create a service in this way the web.config is altered as below:
The examples that Im working off however use DomainServices.i.e. when using these you inherit from DomainService. So i deleted the TerritoryService I had created and then created a DomainService Class from the template off the Web templates menu in Visual Studio. I carried on working and everything compiled just fine. But when i ran it i got an error as per the title of this question.
The problem it turns out is that when you inherit from a domain service no such entry is created in the web.config file. It doesn't need it. But when you delete a service created via the Silverlight-enabled web service it does NOT delete the entry in the web.config file.
So because I had named both services the TerritoryService when the service was being called the entry in the web.config was pulled into play and the server went looking for a service defined in that manner which it could not find because i had deleted it.
So the solution was to simply delete the entry stubs as above that had been auto created by Visual Studio in the config file but not auto deleted by Visual Studio when i deleted the service. Once i did that the problem was resolved.
It took me a half hour to work this out though because of the naming "conflict". It "looked" very much right and was in line with many examples. So if you're inheriting from a domain service class you do not need/should not have an entry in the config file as you do when you've created a wcf service.