azure - 无法将类型 'System.__ComObject' 的 COM 对象强制转换为接口(interface)类型“IFabricNodeContextResult2”

标签 azure azure-service-fabric

启动有状态服务时出现以下异常,导致服务无法完全启动。如何解决此异常并启动服务?

System.InvalidCastException HResult=0x80004002 Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricNodeContextResult2'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{472BF2E1-D617-4B5C-A91D-FABED9FF3550}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). Source=mscorlib StackTrace: at System.StubHelpers.InterfaceMarshaler.ConvertToManaged(IntPtr pUnk, IntPtr itfMT, IntPtr classMT, Int32 flags) at System.Fabric.Interop.NativeRuntime.FabricEndGetNodeContext(IFabricAsyncOperationContext context) at System.Fabric.FabricRuntime.NativeFabricRuntimeFactory.GetNodeContextEndWrapper(IFabricAsyncOperationContext context) at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ServiceFabric.Services.Runtime.RuntimeContext.d__14.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ServiceFabric.Services.Runtime.ServiceRuntime.d__0.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at PrintFileStatelessService.Program.Main() in C:\MyCompany\Current\ServiceFabric\MyCompany.MicroServices\PrintFileStatelessService\Program.cs:line 35

这是我在该服务上拥有的 nuget 软件包。

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.ServiceFabric" version="6.1.467" targetFramework="net461" />
  <package id="Microsoft.ServiceFabric.Data" version="3.0.467" targetFramework="net461" />
  <package id="Microsoft.ServiceFabric.Diagnostics.Internal" version="3.0.467" targetFramework="net461" />
  <package id="Microsoft.ServiceFabric.FabricTransport.Internal" version="3.0.467" targetFramework="net461" />
  <package id="Microsoft.ServiceFabric.Services" version="3.0.467" targetFramework="net461" />
  <package id="Microsoft.ServiceFabric.Services.Remoting" version="3.0.467" targetFramework="net461" />
</packages>

这是代码

namespace PrintFileStatefulService
{
    /// <summary>
    /// An instance of this class is created for each service replica by the Service Fabric runtime.
    /// </summary>
    internal sealed class PrintFileStatefulService : StatefulService, IPrintFileService
    {
        public PrintFileStatefulService(StatefulServiceContext context)
            : base(context)
        { }

        public Task GeneratePrintFile(Guid duesbillingId)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Optional override to create listeners (e.g., HTTP, Service Remoting, WCF, etc.) for this service replica to handle client or user requests.
        /// </summary>
        /// <remarks>
        /// For more information on service communication, see https://aka.ms/servicefabricservicecommunication
        /// </remarks>
        /// <returns>A collection of listeners.</returns>
        protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
        {
            //return new ServiceReplicaListener[0];
            return new[]
            {
                new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context))
            };
        }



    }
}

最佳答案

我遇到了同样的问题,并发现this thread 。事实证明本地服务结构 SDK 需要更新,一旦我更新它就重新开始工作。

Service Fabric SDK 的下载链接:http://www.microsoft.com/web/handlers/webpi.ashx?command=getinstallerredirect&appid=MicrosoftAzure-ServiceFabric-CoreSDK

(或者,如果您不喜欢单击想要安装某些内容的链接,请转到此处并找到(相同的)链接: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-get-started )

关于azure - 无法将类型 'System.__ComObject' 的 COM 对象强制转换为接口(interface)类型“IFabricNodeContextResult2”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49039954/

相关文章:

azure-service-fabric - 为 azure 服务结构部署仅配置升级包

c# - 使用 Autofac 注册 IReliableStateManagerReplica

Azure 数据工厂 UI - 作者和监视器不加载

rest - Azure 调度程序 -;底层连接已关闭: Could not establish trust relationship for the SSL/TLS secure channel

azure - 使用存储池调整 Azure 虚拟机上的磁盘大小

Azure函数: Is there any way to handle TimerTrigger from Azure SDK?

azure-service-fabric - 服务结构 - 每个分区的有状态服务单个实例

azure - 微软Azure : user id does not exist

azure-service-fabric - 如何自定义服务 list 文件的创建?

azure - Service Fabric - 可靠的字典加密模型