I have an issue when I try to build connection for SignalR hub from VSIX project.
Visual studio 2022
VSIX project:
TargetFramework: .Net framework 4.7.2
Signal R lib
Lib name: Microsoft.AspNetCore.SignalR.Client
version: 7.0.5
// MyCoolCommand.cs
/// <summary>
/// Command handler
/// </summary>
internal sealed class MyCoolCommand
{
// some init code. I did change nothing
private void Execute(object sender, EventArgs e)
{
var url = "http://localhost:9200/myHub";
// will fail
var connection = new HubConnectionBuilder()
.WithUrl(url)
.WithAutomaticReconnect()
.Build();
}
}
Exception info:
System.IO.FileNotFoundException: ‘Could not load file or assembly ‘Microsoft.Extensions.Options, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60′ or one of its dependencies. The system cannot find the file specified.’
How to repeat in your local machine:
-
create VSIX project
-
add command
-
add Microsoft.AspNetCore.SignalR.Client from nuger
-
in your command copy code from this example
-
run
-
I tried to change .net framework version – didn’t helped
-
Microsoft.Extensions.Options
is one of sub deps for ‘Microsoft.AspNetCore.SignalR.Client’. I double checked and this lib is exist in the output after build. -
I also tried to add
Microsoft.Extensions.Options
manually to the place where devenv.exe lives.
after this I started to see the same exception but in this timeSystem.Runtime
is missing.
I think it somehow releated with runtime.
2
Answers
Answer: In my case changing the version of signal r client helped. From 7.0.5 to 7.0.0.
Maybe it somehow related with avaliable runtime on your machine.
You are mixing .NET Framework and .NET CORE libraries that are not compatible with each other.
This link explains the differences between the two.
Follow the documentation for using .NET Framework version. Here is the repo as well – https://github.com/SignalR/SignalR