0

Error: Does not contain a definition for 'CreateServiceRemotingListener' and no extension method 'CreateServiceRemotingListener' accepting a first argument of type could be found (are you missing a using directive or an assembly reference?)

Below are the steps which I followed,

  1. Created an interface that implements IService.

    `

        using Microsoft.ServiceFabric.Services.Remoting;
        using System.Threading.Tasks;
        public interface IFileService: IService
        {
            Task<string> GetStringByName(string name);
        }
    

    `

  2. Included following packages in stateful service named as FileService.

    `

     using System. Fabric;
        using Microsoft.ServiceFabric.Data;
        using Microsoft.ServiceFabric.Data.Collections;
        using Microsoft.ServiceFabric.Services.Communication.Runtime;
        using Microsoft.ServiceFabric.Services.Runtime;
    

    `

  3. Implemented IFileService interface in FileService.

    `

     internal sealed class FileService : StatefulService, IFileService
        {
            public FileService(StatefulServiceContext context)
                : base(context)
            { }
            public FileService(StatefulServiceContext context, IReliableStateManagerReplica stateManagerReplica) : base(context, stateManagerReplica)
            {
            }
    
            public Task<string> GetStringByName(string name)
            {
                return Task.FromResult<string>(name);
            }
    
    
            /// <summary>
            /// Optional override to create listeners (e.g., HTTP, Service Remoting, WCF, etc.) for this service replica to handle client or user requests.
            /// </summary>
            /// <remarks>
            /// For more information on service communication, see https://aka.ms/servicefabricservicecommunication
            /// </remarks>
            /// <returns>A collection of listeners.</returns>
            protected override IEnumerable<ServiceReplicaListener> 
    
        CreateServiceReplicaListeners()
                {
                    return new[] { new ServiceReplicaListener(this.CreateServiceRemotingListener) };
                }}
    

    `

1 Answers1

3

The ServiceRemotingExtensions class is located in Microsoft.ServiceFabric.Services.Remoting.Runtime namespace (that isn't included).

The important point to mention is that CreateServiceRemotingListener is deprecated. The recommended method to use is CreateServiceRemotingReplicaListeners.

Hope this helps.


UPDATE 2019/01/28

Here is the sample code:

using System.Collections.Generic;
using System.Fabric;

using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Remoting;
using Microsoft.ServiceFabric.Services.Remoting.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;

namespace JustService
{
    public interface IRemotingService : IService
    {
        // Remoting methods
    }
    internal sealed class JustService : StatefulService, IRemotingService
    {
        public JustService(
            StatefulServiceContext context)
            : base(context)
        {
        }
        protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
        {
            return this.CreateServiceRemotingReplicaListeners();
        }
    }
}

Please note that in order to use CreateServiceRemotingReplicaListeners extension method the service should implement an interface derived from IService.

Oleg Karasik
  • 959
  • 6
  • 17