ServiceFabric / IFabricSecretStoreClient / COM异常

时间:2018-12-08 22:53:23

标签: azure-service-fabric visual-studio-2019

我在这方面没有发现太多,花了一天的大部分时间后...我正在寻求帮助。

我得到的例外是:

  

无法将类型为'System .__ ComObject'的COM对象转换为接口   键入“ IFabricSecretStoreClient”。该操作失败,因为   IID接口的COM组件上的QueryInterface调用   “ {38C4C723-3815-49D8-BDF2-68BFB536B8C9}”由于以下原因而失败   错误:不支持此类接口(HRESULT的异常:0x80004002   (E_NOINTERFACE)。

我可以使用以下代码实例化有状态服务的代理:

var servicekey = new ServicePartitionKey(0);
  var queryserviceUri = new Uri("fabric:/XXXX/xxxxxxxxxx");
  var proxyHandle = ServiceProxy.Create<IAnInterfaceName>(queryserviceUri, servicekey, TargetReplicaSelector.PrimaryReplica);

然后我使用代理服务器:

var result = await proxyHandle.OperationOnServiceContract(dataPackage);

这时我得到了错误...

Stacktrace ...

  

at System.Fabric.FabricClient.CreateNativeClient(IEnumerable 1 connectionStringsLocal) at System.Fabric.Interop.Utility.<>c__DisplayClass27_0.<WrapNativeSyncInvoke>b__0() at System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func 1   func,String functionTag,String functionArgs)位于   System.Fabric.Interop.Utility.WrapNativeSyncInvoke(动作,   字符串functionTag,字符串functionArgs)在   System.Fabric.Interop.Utility.RunInMTA(Action操作)位于   System.Fabric.FabricClient.InitializeFabricClient(SecurityCredentials   credentialArg,FabricClientSettings newSettings,字符串[]   hostEndpointsArg)   Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver。<> c.b__21_0()   在   Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.GetClient()   在   Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.ResolveHelperAsync(Func 5 resolveFunc, ResolvedServicePartition previousRsp, TimeSpan resolveTimeout, TimeSpan maxRetryInterval, CancellationToken cancellationToken, Uri serviceUri) at Microsoft.ServiceFabric.Services.Communication.Client.CommunicationClientFactoryBase 1.GetClientAsync(Uri   serviceUri,ServicePartitionKey partitionKey,TargetReplicaSelector   targetReplicaSelector,字符串listenerName,OperationRetrySettings   retrySettings,CancellationToken cancelToken)   Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Client.FabricTransportServiceRemotingClientFactory.GetClientAsync(Uri   serviceUri,ServicePartitionKey partitionKey,TargetReplicaSelector   targetReplicaSelector,字符串listenerName,OperationRetrySettings   retrySettings,CancellationToken cancelToken)   Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient 1.GetCommunicationClientAsync(CancellationToken cancellationToken) at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient 1.InvokeWithRetryAsync [TResult](Func 2 func, CancellationToken cancellationToken, Type[] doNotRetryExceptionTypes) at Microsoft.ServiceFabric.Services.Remoting.V2.Client.ServiceRemotingPartitionClient.InvokeAsync(IServiceRemotingRequestMessage remotingRequestMessage, String methodName, CancellationToken cancellationToken) at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.InvokeAsyncV2(Int32 interfaceId, Int32 methodId, String methodName, IServiceRemotingRequestMessageBody requestMsgBodyValue, CancellationToken cancellationToken) at Microsoft.ServiceFabric.Services.Remoting.Builder.ProxyBase.ContinueWithResultV2[TRetval](Int32 interfaceId, Int32 methodId, Task 1任务)位于   XXXXWeb.Controllers.XXXController.OperationOnServiceContract(XXXRequest   xxxRequest)中   C:\ Users \ codputer \ Source \ Repos \ xxxxxx \ xxxx.Web \ Controllers \ XXXController.cs:line   44

哦,我正在用它作为听众:

protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
{
  return this.CreateServiceRemotingReplicaListeners();
}

1 个答案:

答案 0 :(得分:3)

关于这些问题的说明:

每当您使用针对较旧版本的Service Fabric运行时的更新的Nuget包时,就会发生这些COM问题,就会发生这种错误。

您应该始终使用针对相同集群运行时版本的软件包,在最后一种情况下,请使用早于集群版本的软件包。