无法将类型为"System .__ ComObject"的COM对象转换为接口类型为"IFabricNodeContextResult2" [英] Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricNodeContextResult2
问题描述
启动有状态服务时出现以下异常,这会阻止该服务完全启动.如何解决此异常并启动服务?
I am getting the following exception when starting a Stateful Service which prevents the service from fully starting. How do I resolve this exception and get the service to start?
System.InvalidCastExceptionHResult = 0x80004002Message =无法将类型为"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上下文,布尔值ExpectCompletedSynchronously)在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任务)在Microsoft.ServiceFabric.Services.Runtime.RuntimeContext.d__14.MoveNext()在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任务)在Microsoft.ServiceFabric.Services.Runtime.ServiceRuntime.d__0.MoveNext()在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任务)在System.Runtime.CompilerServices.TaskAwaiter.GetResult()在C:\ MyCompany \ Current \ ServiceFabric \ MyCompany.MicroServices \ PrintFileStatelessService \ Program.cs:line中的PrintFileStatelessService.Program.Main()处35
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软件包.
Here are the nuget packages that I have on this service.
<?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))
};
}
}
}
推荐答案
I had the same problem, and found this thread. Turns out the local service fabric SDK needed updating, once I did that it started working again.
Download link for the service fabric SDK: http://www.microsoft.com/web/handlers/webpi.ashx?command=getinstallerredirect&appid=MicrosoftAzure-ServiceFabric-CoreSDK
(或者,如果您不喜欢单击想要安装某些东西的链接,请转到此处并找到(相同)链接:
(Or if you don't like clicking a link that wants to install something, go here and find the (same) link: https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-get-started)
这篇关于无法将类型为"System .__ ComObject"的COM对象转换为接口类型为"IFabricNodeContextResult2"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!