Cannot have two operations in the same contract with the same name (Async & Non)

后端 未结 5 1724
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 15:15

I get the following exception (Cannot have two operations in the same contract with the same name, methods ExecuteAsync and Execute) when the following service is activated.

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-01 15:58

    Try adding the name in OperationMethod to make it more simpler.

    [ServiceContract]
    public interface IMyService
    {
        [OperationContract(Name = "Service1")]
        byte[] Execute(MyRequest request);
    
        [OperationContract(Name = "Service2")]
        Task ExecuteAsync(MyRequest request);
    }
    

提交回复
热议问题