错误:不包含“CreateServiceRemotingListener”的定义,并且找不到接受第一个类型参数的扩展方法“CreateServiceRemotingListener”(您是否缺少 using 指令或程序集引用?)
以下是我遵循的步骤,
创建了一个实现 IService 的接口。
`
using Microsoft.ServiceFabric.Services.Remoting; using System.Threading.Tasks; public interface IFileService: IService { Task<string> GetStringByName(string name); }
`
在名为 FileService 的有状态服务中包含以下包。
`
using System. Fabric; using Microsoft.ServiceFabric.Data; using Microsoft.ServiceFabric.Data.Collections; using Microsoft.ServiceFabric.Services.Communication.Runtime; using Microsoft.ServiceFabric.Services.Runtime;
`
在 FileService 中实现了 IFileService 接口。
`
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) }; }}
`