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

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

  •  02-04-2022
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top