SvcUtil is not generating a class derived from DuplexClientBase despite the ServiceContract defining a CallbackContract

StackOverflow https://stackoverflow.com/questions/15865296

  •  02-04-2022
  •  | 
  •  

When I use SvcUtil.exe to generate a proxy of my service, I get a class derived from ClientBase even though I declare a CallbackContract. This is the service contract:

[ServiceContract(CallbackContract = typeof(IMechClient))]
interface IMechService
{
    [OperationContract(IsOneWay = true)]
    void Increment();

    [OperationContract]
    bool RegisterPlayer();
}

And this is the generated proxy header:

public partial class MechServiceClient : System.ServiceModel.ClientBase<IMechService>, IMechService

Obviously I could manually edit the proxy, but as this project is still in the works, I'll have to regenerate the proxy numerous times and would rather learn the correct way now rather than keep manually tweaking the proxy file every time I recompile.

有帮助吗?

解决方案

By attempting to create the proxy using DuplexChannelFactory instead, I received a different error and figured out you need to implement an OperationContract in the Callback interface first or else the CallbackContract is ignored, thus not deriving from DuplexClientBase.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top