views:

205

answers:

1

Hi,

I have a public interface auto-generated bu svcutil:

[System.ServiceModel.ServiceContractAttribute(Namespace="...", ConfigurationName="...")]
public interface MyInterface

Then I have asmx web service inheriting it and working fine. I am trying ot convert it to WCF but when I instrument the service (in asmx.cs code behind) with ServiceContract:

[ServiceContract(Namespace = "...")]
public class MyService : MyInterface 

Also I have cerated .svc file and added the system.serviceModel setting in the config file. The goal is to migrate the asmx service to WCF service.

I've got this error:

The service class of type MyService both defines a ServiceContract and inherits a ServiceContract from type MyInterface. Contract inheritance can only be used among interface types. If a class is marked with ServiceContractAttribute, it must be the only type in the hierarchy with ServiceContractAttribute.

The asmx service is still working fine. Only the .svc is giving me issues. My question is how to fix that. MyInterface is an interface so I do not see what the problem is and why I've got the error anyway.

Note I do not want to change MyInterface, because it is autogenerated from svcutil from my wsdl schema and I do not want this interface to be edited manually. The whole idea is to have the service types automatically genereted from WSDL and to save my team development efforts with manual editing.

Any help is appreciated.

A: 

You need to remove the ServiceContractAttribute from MyService class. This attribute is already defined in the interface and that's the correct way of specifying that this interface will be exposed as WCF service.

Darin Dimitrov
thanks for the annswer, that what I taught but when I remove the service contract I've got this error:The contract name 'MyService' could not be found in the list of contracts implemented by the service 'MyService'.
Valko
it works now just wrong name for contract in my config file so thank you for the help :-)
Valko