microsoft / service-fabric

Service Fabric is a distributed systems platform for packaging, deploying, and managing stateless and stateful distributed applications and containers at large scale.
https://docs.microsoft.com/en-us/azure/service-fabric/
MIT License
3.03k stars 401 forks source link

[BUG] Getting System.InvalidCastException after updating SDK to 7.1.1951 and Runtime to 10.1.1951 #1495

Open hedinaili opened 7 months ago

hedinaili commented 7 months ago

Getting this exception after updating the SDK and runtime to versions 7.1.1951 to 10.1.1951 respectively

System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricServiceManagementClient8'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{27309DB9-61A7-AE11-967A-BBFF7D5A5460}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

part of the stack trace

"System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricServiceManagementClient8'. 
This operation failed because the QueryInterface call on the COM component for the interface with IID '
{27309DB9-61A7-AE11-967A-BBFF7D5A5460}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).\r\n  
 at System.Fabric.FabricClient.CreateNativeClient(IEnumerable`1 connectionStringsLocal)\r\n   at System.Fabric.Interop.Utility.<>c__DisplayClass28_0.<WrapNativeSyncInvoke>b__0()\r\n  
 at System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func`1 func, String functionTag, String functionArgs)\r\n   
 at System.Fabric.Interop.Utility.RunInMTA(Action action)\r\n 
 at System.Fabric.FabricClient.InitializeFabricClient(SecurityCredentials credentialArg, FabricClientSettings newSettings, String[] hostEndpointsArg)\r\n  
 at Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.<>c.<GetDefault>b__22_0()\r\n  
 at Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.GetClient()\r\n 
 at Microsoft.ServiceFabric.Services.Client.ServicePartitionResolver.<ResolveHelperAsync>d__30.MoveNext()
 \r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n  
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n  
 at Microsoft.ServiceFabric.Services.Communication.Client.CommunicationClientFactoryBase`1.<GetClientAsync>d__24.MoveNext()
 \r\n--- End of stack trace from previous location where exception was thrown ---\r\n   
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   
 at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<GetCommunicationClientAsync>d__28.MoveNext()
 \r\n--- End of stack trace from previous location where exception was thrown ---\r\n   
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
 at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__23`1.MoveNext()
 \r\n--- End of stack trace from previous location where exception was thrown ---\r\n   
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n  
 at Microsoft.ServiceFabric.Services.Communication.Client.ServicePartitionClient`1.<InvokeWithRetryAsync>d__25.MoveNext()

The code invoking this was not changed

tuhland commented 7 months ago

This usually occurs when the SF nuget packages are way too old, or ahead of the installed sdk / runtime version.

hedinaili commented 7 months ago

@tuhland I mentioned the versions used, they are the current ones

tuhland commented 7 months ago

Yes I know.

What I meant is, that this error usually occurs when the nuget packages your application uses differ too much from the installed cluster version. Updating the nuget packages and not the cluster runtime (either local or in the cloud) is a sure fire way to get this error.

We run into this frequently when we update the nuget packages and some of the devs did not update their local development cluster to the latest version Which most if them don't do, because it's a tedious manual process.

So make sure you not only updated the packages to the latest version, but also downloaded and installed the SDK / Runtime from here: https://github.com/microsoft/service-fabric/blob/master/release_notes/Service_Fabric_ReleaseNotes_101CU2.md

If you did both, this might be a different issue.

hedinaili commented 7 months ago

@tuhland SDK and runtime versions are 7.1.1951 to 10.1.1951 respectively which are the current ones..