Software & Finance





Visual Studio.NET - WCF Exception with Wrong Contract Name





 

Here is the information on how to fix the WCF Exception with wrong contract name.

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

 

This error is caused when you have misspelled the contract name in the endpoint  under services/service section like below:

 

                 <endpoint  address=""

                 binding="basicHttpBinding"

                 contract="Wcf_Test_Service.ITestService2" >

        </endpoint>

 

 

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

 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The contract name 'Wcf_Test_Service.ITestService2' could not be found in the list of contracts implemented by the service 'TestService'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

 
[InvalidOperationException: The contract name 'Wcf_Test_Service.ITestService2' could not be found in the list of contracts implemented by the service 'TestService'.]
   System.ServiceModel.Description.ConfigLoader.LookupContract(String contractName, String serviceName) +12229213
   System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +12227837
   System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +67
   System.ServiceModel.ServiceHostBase.ApplyConfiguration() +108
   System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +192
   System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49
   System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +151
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +30
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +420
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615
 
[ServiceActivationException: The service '/wcftestservice/TestService.svc' cannot be activated due to an exception during compilation.  The exception message is: The contract name 'Wcf_Test_Service.ITestService2' could not be found in the list of contracts implemented by the service 'TestService'..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +679246
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
   System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult ar) +300622
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +8837348