跟进问题至 How can I compose a WCF contract out of multiple interfaces? .
我试图在一个接口中合并多个回调接口。这将生成一个InvalidOperationException,声明最终接口不包含任何操作。从技术上讲,这是正确的,但是继承的接口确实包含操作。
我怎么修这个?或者这是WCF的限制?
编辑:
[ServiceContract] // Using the following line instead would be no problem for me: // [ServiceContract (CallbackContract = CallbackA)] interface ServiceA { [OperationContract]void X(); } [ServiceContract] // same here interface ServiceB { [OperationContract]void Y(); } interface CallbackA { [OperationContract]void CB_A() } // required in ServiceA interface CallbackB { [OperationContract]void CB_B() } // required in ServiceB interface CallbackC: CallbackA, CallbackB {} // composed callback contract [ServiceContract (CallbackContract = CallbackC)] interface ServiceC: ServiceA, ServiceB {} // composed service contract
不看服务合同本身的合同层次结构很难说,但答案可能依赖于以下原则:
"A service contract can only designate a callback contract if that contract is a subinterface of all callback contracts defined by the contract's own base contracts."