ServiceFabric / IFabricSecretStoreClient / COM 异常

ServiceFabric / IFabricSecretStoreClient / COM Exception

我没有找到太多关于这方面的信息,并且在花了一天的大部分时间后...我正在寻求帮助..

我得到的异常是这样的:

Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricSecretStoreClient'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{38C4C723-3815-49D8-BDF2-68BFB536B8C9}' failed due to the following error: No such interface supported (Exception from 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);

此时我得到错误...

堆栈跟踪...

at System.Fabric.FabricClient.CreateNativeClient(IEnumerable1 connectionStringsLocal) at System.Fabric.Interop.Utility.<>c__DisplayClass27_0.<WrapNativeSyncInvoke>b__0() at System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func1 func, String functionTag, String functionArgs) at System.Fabric.Interop.Utility.WrapNativeSyncInvoke(Action action, String functionTag, String functionArgs) at System.Fabric.Interop.Utility.RunInMTA(Action action) at System.Fabric.FabricClient.InitializeFabricClient(SecurityCredentials credentialArg, FabricClientSettings newSettings, String[] hostEndpointsArg) at Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.<>c.b__21_0() at Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.GetClient() at Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.ResolveHelperAsync(Func5 resolveFunc, ResolvedServicePartition previousRsp, TimeSpan resolveTimeout, TimeSpan maxRetryInterval, CancellationToken cancellationToken, Uri serviceUri) at Microsoft.ServiceFabric.Services.Communication.Client.CommunicationClientFactoryBase1.GetClientAsync(Uri serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector targetReplicaSelector, String listenerName, OperationRetrySettings retrySettings, CancellationToken cancellationToken) at Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Client.FabricTransportServiceRemotingClientFactory.GetClientAsync(Uri serviceUri, ServicePartitionKey partitionKey, TargetReplicaSelector targetReplicaSelector, String listenerName, OperationRetrySettings retrySettings, CancellationToken cancellationToken) at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient1.GetCommunicationClientAsync(CancellationToken cancellationToken) at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient1.InvokeWithRetryAsync[TResult](Func2 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, Task1 task) at XXXXWeb.Controllers.XXXController.OperationOnServiceContract(XXXRequest xxxRequest) in C:\Users\codputer\Source\Repos\xxxxxx\xxxx.Web\Controllers\XXXController.cs:line 44

哦,我正在将其用于听众:

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

正如在这些问题上所指出的:

每当您使用针对旧版本服务结构运行时的较新 Nuget 包时,就会发生这些 COM 问题,并会发生此类错误。

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