@Dey, Subir Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I see that you are trying to use Microsoft.AspNetCore.SignalR.Client (6.0.0) in an Azure Function 4.0 (.Net Core Project) and encountering an error while invoking the code. Specifically, the error message states that the type initializer for 'Microsoft.AspNetCore.SignalR.Client.HubConnection' threw an exception, and the system cannot find the file specified.
Based on the error message you provided, it seems that the type initializer for 'Microsoft.AspNetCore.SignalR.Client.HubConnection' threw an exception, and the system cannot find the file specified. This error message can occur due to several reasons, including:
- Missing or incorrect reference to the System.Threading.Channels assembly.
- Incompatible versions of the SignalR client and server libraries.
- Incorrect URL or configuration settings.
To resolve this issue, you can try the following solutions:
- Firstly, the
Microsoft.AspNetCore.SignalR.Client
6.0 version seems to be an older version. Could you please upgrade it to the most recent stable version 7.0.10 ? See here. - Also Ensure that the
System.Threading.Channels
assembly is referenced correctly in your project. You can check the NuGet package manager to see if the package is installed and up-to-date. If not, you can install it by running the following command in the Package Manager Console:
Install-Package System.Threading.Channels -Version 7.0.0
- Please open your Functions csproj file and check if you have any incorrect dependencies added for
System.Threading.Channels
within thePackageReference
. - Please ensure that it works fine locally (on your VS dev box) at your end before deploying it to the Azure Function.
- Please follow this article and leverage the sample code provided here
- Check if the SignalR client and server libraries are compatible. You can refer to the following documentation to ensure that you are using the correct versions:
If you still encounter the same issue, Please do reach out to me. I would be happy to help.
**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.