Sunday, April 28, 2013

WCF Errors

1. [ServiceContract] attribute can be used only once in the hierarchy.
When interface and class both were decorated with [ServiceContract] attribute, the following error is thrown:

“The service class of type ABCD both defines a ServiceContract and inherits a ServiceContract from type IABCD. 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.  Consider moving the ServiceContractAttribute on type IABCD to a separate interface that type IABCD implements. “

2. The following is self explanatory :

“The OperationContractAttribute declared on method 'GetXYZ' in type 'ABCD' is invalid. OperationContractAttributes are only valid on methods that are declared in a type that has ServiceContractAttribute. Either add ServiceContractAttribute to type 'ABCD' or remove OperationContractAttribute from method 'GetXYZ'. “

3. Following is again self explanatory.
The contract name 'ABCD' could not be found in the list of contracts implemented by the service 'ABCD'.

In this case, IABCD was interface, ABCD was class, IABCD was decorated with [ServiceContract], but "ABCD" was specified as contract in web.config. WCF expected "IABCD" to be specified in web.config, and not "ABCD" as contract.

No comments:

Post a Comment