【问题标题】:cannot start up service fabric service无法启动服务结构服务
【发布时间】:2017-03-20 13:10:06
【问题描述】:

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

代码与书中大致相同,服务(WCF)是这样创建的:

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

第一次调用服务时,调用永远挂起,服务结构浏览器给出以下错误+堆栈跟踪:

不健康事件:SourceId='System.RA'、Property='ReplicaOpenStatus'、 HealthState='警告',考虑WarningAsError=false。副本有 打开期间多次失败。错误 =System.InvalidOperationException (-2146233079) Poging om contracttype voor ICalculatorService te verkrijgen, maar dat type is geen ServiceContract en neemt ook geen ServiceContract 结束。比杰 System.ServiceModel.Description.ServiceReflector.GetContractTypeAndAttribute(类型 interfaceType, ServiceContractAttribute&contractAttribute) bij System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(类型 contractType, Type serviceType, Object serviceImplementation) bij System.ServiceModel.Description.ContractDescription.GetContract(类型 合同类型)bij Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener1.CreateServiceEndpoint(Type contractType, Binding binding, EndpointAddress address) bij Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener1..ctor(ServiceContext serviceContext,TServiceContract wcfServiceObject,绑定 listenerBinding, EndpointAddress 地址, String endpointResourceName) 比杰 Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener`1..ctor(ServiceContext serviceContext,TServiceContract wcfServiceObject,绑定 listenerBinding, String endpointResourceName) bij CalculatorService.CalculatorService.b__3_0(StatelessServiceContext initParams) 在 C:\Users\servel\documents\visual studio 2015\Projects\CalculatorApplication\CalculatorService\CalculatorService.cs:regel 45 比杰 Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__10.MoveNext() 比杰 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)bij System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)bij Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__0.MoveNext()

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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 哈哈哈所有新信息我忘了添加 [ServiceContract] 到界面。谢谢!
    猜你喜欢
    • 2021-04-05
    • 2016-02-04
    • 1970-01-01
    • 1970-01-01
    • 2022-12-21
    • 2019-03-28
    • 2016-04-23
    • 2015-11-17
    相关资源
    最近更新 更多