Search code examples
c#wcfwcfserviceclient

how to avoid in WCF service interface to implementing either synchronous or asynchronous Method


I have implemented WCF Services, I have defined synchronize method as following;

[ServiceContract]
public interface IMarketingCampaignType
{
    [OperationContract]
    List<MarketingCampaignTypeData> GetAllCampaignTypes();

    [OperationContract]
    MarketingCampaignTypeData GetCampaignTypeByID(int CampaignTypeID);

    [OperationContract]
    MarketingCampaignTypeData CreateNewCampaignType();

    [OperationContract]
    MarketingCampaignTypeData EditCampaignType();

    [OperationContract]
    bool DeleteCampaignType();
}

Now on client side when I configure this service by choosing 'Add Service Reference' in visual studio under project, interface is generated under namespace 'App.Client.Proxies.MarketingCampaignTypeServiceRef'

but when I am implement this interface I am getting two of each methods for each implementation one synchronous and other asynchronous. I know that in client only you choose which one you want to implement but my question can I can control which one I am allowing or just have one type of method instead of two?

here is interface implementation of service

 public class MarketingCampaignTypeClient : IMarketingCampaignType
 {
    public MarketingCampaignTypeData CreateNewCampaignType()
    {
        throw new NotImplementedException();
    }

    public Task<MarketingCampaignTypeData> CreateNewCampaignTypeAsync()
    {
        throw new NotImplementedException();
    }

    public bool DeleteCampaignType()
    {
        throw new NotImplementedException();
    }

    public Task<bool> DeleteCampaignTypeAsync()
    {
        throw new NotImplementedException();
    }

    public MarketingCampaignTypeData EditCampaignType()
    {
        throw new NotImplementedException();
    }

    public Task<MarketingCampaignTypeData> EditCampaignTypeAsync()
    {
        throw new NotImplementedException();
    }

    public MarketingCampaignTypeData[] GetAllCampaignTypes()
    {
        throw new NotImplementedException();
    }

    public Task<MarketingCampaignTypeData[]> GetAllCampaignTypesAsync()
    {
        throw new NotImplementedException();
    }

    public MarketingCampaignTypeData GetCampaignTypeByID(int CampaignTypeID)
    {
        throw new NotImplementedException();
    }

    public Task<MarketingCampaignTypeData> GetCampaignTypeByIDAsync(int CampaignTypeID)
    {
        throw new NotImplementedException();
    }

Solution

  • Make sure, you have unchecked this in your Serviceconfig:

    Disable async