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.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
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>
And here is the code
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))
};
}
}
}