英文:
Using aspnet core SignalR client for VSIX project
问题
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 related to runtime.
英文:
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.
答案1
得分: 0
你正在混合使用不兼容的.NET Framework和.NET CORE库。
这个链接解释了两者之间的差异。
请按照使用.NET Framework版本的文档。这里也有存储库 - https://github.com/SignalR/SignalR。
英文:
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
答案2
得分: 0
在我的情况下,更改SignalR客户端的版本有所帮助。
从7.0.5改为7.0.0。
也许这与您的计算机上可用的运行时相关。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论