无法启动服务结构服务
cannot start up service fabric service
在按照 Azure Service Fabric 编程中有关创建计算器服务的 WcfCommunicationClient 的教程进行操作时,我偶然发现了一个我找不到答案的问题。
代码与书中大致相同,服务 (WCF) 是这样创建的:
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[]
{
new ServiceInstanceListener(initParams => new WcfCommunicationListener<ICalculatorService>(initParams, this, WcfUtility.CreateTcpListenerBinding(), "ServiceEndpoint"))
};
}
第一次调用该服务时,调用永远挂起,Service Fabric Explorer 给出以下错误 + 堆栈跟踪:
Unhealthy event: SourceId='System.RA', Property='ReplicaOpenStatus',
HealthState='Warning', ConsiderWarningAsError=false. Replica had
multiple failures during open. Error =System.InvalidOperationException
(-2146233079) Poging om contracttype voor ICalculatorService te
verkrijgen, maar dat type is geen ServiceContract en neemt ook geen
ServiceContract over. bij
System.ServiceModel.Description.ServiceReflector.GetContractTypeAndAttribute(Type
interfaceType, ServiceContractAttribute& contractAttribute) bij
System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type
contractType, Type serviceType, Object serviceImplementation) bij
System.ServiceModel.Description.ContractDescription.GetContract(Type
contractType) bij
Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener1.CreateServiceEndpoint(Type
contractType, Binding binding, EndpointAddress address) bij
Microsoft.ServiceFabric.Services.Communication.Wcf.Runtime.WcfCommunicationListener
1..ctor(ServiceContext
serviceContext, TServiceContract wcfServiceObject, Binding
listenerBinding, EndpointAddress address, 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) in C:\Users\servel\documents\visual studio
2015\Projects\CalculatorApplication\CalculatorService\CalculatorService.cs:regel
45 bij
Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__10.MoveNext()
bij
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) bij
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) bij
Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__0.MoveNext()
显然服务无法启动。那么如何解决这个问题?
确保您的服务实现了具有 WCF ServiceContract
和 OperationContract
属性的接口。像这个例子 here.
在按照 Azure Service Fabric 编程中有关创建计算器服务的 WcfCommunicationClient 的教程进行操作时,我偶然发现了一个我找不到答案的问题。
代码与书中大致相同,服务 (WCF) 是这样创建的:
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[]
{
new ServiceInstanceListener(initParams => new WcfCommunicationListener<ICalculatorService>(initParams, this, WcfUtility.CreateTcpListenerBinding(), "ServiceEndpoint"))
};
}
第一次调用该服务时,调用永远挂起,Service Fabric Explorer 给出以下错误 + 堆栈跟踪:
Unhealthy event: SourceId='System.RA', Property='ReplicaOpenStatus', HealthState='Warning', ConsiderWarningAsError=false. Replica had multiple failures during open. Error =System.InvalidOperationException (-2146233079) Poging om contracttype voor ICalculatorService te verkrijgen, maar dat type is geen ServiceContract en neemt ook geen ServiceContract over. bij System.ServiceModel.Description.ServiceReflector.GetContractTypeAndAttribute(Type interfaceType, ServiceContractAttribute& contractAttribute) bij System.ServiceModel.Description.TypeLoader.LoadContractDescriptionHelper(Type contractType, Type serviceType, Object serviceImplementation) bij System.ServiceModel.Description.ContractDescription.GetContract(Type 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 address, 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) in C:\Users\servel\documents\visual studio 2015\Projects\CalculatorApplication\CalculatorService\CalculatorService.cs:regel 45 bij Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__10.MoveNext() bij System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bij System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bij Microsoft.ServiceFabric.Services.Runtime.StatelessServiceInstanceAdapter.d__0.MoveNext()
显然服务无法启动。那么如何解决这个问题?
确保您的服务实现了具有 WCF ServiceContract
和 OperationContract
属性的接口。像这个例子 here.