【问题标题】:Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricNodeContextResult2无法将“System.__ComObject”类型的 COM 对象转换为接口类型“IFabricNodeContextResult2”
【发布时间】:2018-08-08 22:42:53
【问题描述】:

我在启动有状态服务时遇到以下异常,这会阻止服务完全启动。如何解决此异常并启动服务?

System.InvalidCastException H结果=0x80004002 消息=无法将“System.__ComObject”类型的 COM 对象转换为接口类型“IFabricNodeContextResult2”。此操作失败 因为接口的 COM 组件上的 QueryInterface 调用 使用 IID '{472BF2E1-D617-4B5C-A91D-FABED9FF3550}' 失败,因为 以下错误:不支持此类接口(来自 HRESULT 的异常: 0x80004002 (E_NOINTERFACE))。 源=mscorlib 堆栈跟踪: 在 System.StubHelpers.InterfaceMarshaler.ConvertToManaged(IntPtr pUnk, IntPtr itfMT、IntPtr classMT、Int32 标志) 在 System.Fabric.Interop.NativeRuntime.FabricEndGetNodeContext(IFabricAsyncOperationContext 语境) 在 System.Fabric.FabricRuntime.NativeFabricRuntimeFactory.GetNodeContextEndWrapper(IFabricAsyncOperationContext 语境) 在 System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext 上下文,布尔预期CompletedSynchronously) 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) 在 Microsoft.ServiceFabric.Services.Runtime.RuntimeContext.d__14.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) 在 Microsoft.ServiceFabric.Services.Runtime.ServiceRuntime.d__0.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) 在 System.Runtime.CompilerServices.TaskAwaiter.GetResult() 在 C:\MyCompany\Current\ServiceFabric\MyCompany.MicroServices\PrintFileStatelessService\Program.cs:line 中的 PrintFileStatelessService.Program.Main() 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))
            };
        }



    }
}

【问题讨论】:

  • 请提出一个明确的问题。
  • 需要更多背景信息来了解您在做什么。

标签: azure azure-service-fabric


【解决方案1】:

尝试在您的 PC 上更新 Service Fabric SDK,如果您的 SDK 与您使用的 nuget 包不匹配,有时会出现奇怪的错误。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,找到了this thread。原来本地服务结构 SDK 需要更新,一旦我这样做了,它又开始工作了。

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

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

    【讨论】:

      猜你喜欢
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-20
      • 2010-12-02
      • 1970-01-01
      • 2016-02-02
      相关资源
      最近更新 更多