无法启动服务结构服务

时间:2016-11-07 08:44:54

标签: web-services wcf azure-service-fabric

在遵循Azure Service Fabric编程中关于创建计算器服务的WcfCommunicationClient的教程时,我偶然发现了一个无法找到答案的问题。

代码与书中的代码大致相同,服务(WCF)的创建方式如下:

    protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
  return new[]
  {
    new ServiceInstanceListener(initParams => new WcfCommunicationListener<ICalculatorService>(initParams, this, WcfUtility.CreateTcpListenerBinding(), "ServiceEndpoint"))
  };
}

第一次调用该服务时,该调用将永久挂起,并且服务结构资源管理器会出现以下错误+ stacktrace:

  

不健康的事件:SourceId =&#39; System.RA&#39;,Property =&#39; ReplicaOpenStatus&#39;,   HealthState =&#39;警告&#39;,ConsideWarningAsError = false。复制品了   打开期间多次失败。 Error = System.InvalidOperationException   (-2146233079)Poging om contracttype voor ICalculatorService te   verkrijgen,maar dat type is geen ServiceContract en neemt ook geen   ServiceContract结束。 BIJ   System.ServiceModel.Description.ServiceReflector.GetContractTypeAndAttribute(类型   interfaceType,ServiceContractAttribute&amp; contractAttribute)bij   System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(类型   contractType,Type serviceType,Object serviceImplementation)bij   System.ServiceModel.Description.ContractDescription.GetContract(类型   contractType)bij   Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener 1.CreateServiceEndpoint(Type contractType, Binding binding, EndpointAddress address) bij Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener 1..ctor(ServiceContext   serviceContext,TServiceContract wcfServiceObject,Binding   listenerBinding,EndpointAddress地址,String endpointResourceName)   BIJ   Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener`1..ctor(ServiceContext   serviceContext,TServiceContract wcfServiceObject,Binding   listenerBinding,String endpointResourceName)bij   CalculatorService.CalculatorService.b__3_0(StatelessServiceContext   initParams)在C:\ Users \ servel \ documents \ visual studio中   2015年\项目\ CalculatorApplication \ CalculatorService的\ CalculatorService.cs:葱   45 bij   Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__10.MoveNext()   BIJ   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)bij   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)bij   Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__0.MoveNext()

显然服务无法启动。那么该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

确保您的服务实现了具有WCF ServiceContractOperationContract属性的接口。就像这个例子here