.Net 6 – 哪些 C# SignalR 客户端/服务器包?

huangapple go评论129阅读模式
英文:

.Net 6 - which C# SignalR client/server packages?

问题

<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.14" /> 对于客户端项目似乎运行正常。它是一个 .Net 6 项目,因此我假设应该使用最新的 6.x.x 包。这正确吗?那么在服务器端项目上应该使用哪个“匹配的”包?NuGet 上有很多已弃用的包 (V1.10、2.4.2) 和没有意义的版本。

有几个不同的 Microsoft 网站文档线索存在相互矛盾的信息。(所以,是的,我试图研究过这个...)。

有一个“流行”的服务器端版本 2.4.3,但我得到了警告,表示它“可能”与 .Net 6 不兼容。它似乎可以工作,但不确定是否最佳实践匹配这些不太可能的版本。

英文:

Can someone tell me what NuGet package(s) I should be using for a .Net 6 C# SignalR Hub project and a .Net 6 C# SignalR client project?

On the client project, I tried:

&lt;PackageReference Include=&quot;Microsoft.AspNetCore.SignalR.Client&quot; Version=&quot;6.0.14&quot; /&gt;

Which seemed to work fine. It's a .Net 6 project, so I assumed I should be using the latest 6.x.x package. Is this correct? So which 'matching' package should I be using on the server side project? There's a lot of junk in NuGet of deprecated packages (V1.10, 2.4.2) and versions that make no sense.

There's several different threads of documentation on the MS website that has contradictory information on it. (So yes, I did try and research this...)

There was a 'popular' version of server-side version 2.4.3,

&lt;PackageReference Include=&quot;Microsoft.AspNet.SignalR&quot; Version=&quot;2.4.3&quot; /&gt;

but I got warnings saying it 'might' not be compatible with .Net 6. It appeared to work, but not sure it's best practice matching up these unlikely versions.

答案1

得分: 2

你是对的,你想要版本6与NetCore 6兼容。我觉得这并不明显。你可以通过比较以下网址中突出显示的框架版本来验证:

与更高版本:

可以看到SignalR.Client版本6支持net6,而版本7支持net7。

(另外,在依赖项选项卡上,可以看到版本7将引入AspNet 7的依赖项)

服务器端

没有服务器端包,因为它已包含在AspNetCore中,如https://learn.microsoft.com/en-us/aspnet/core/signalr/version-differences?view=aspnetcore-6.0中第一个表格右上角的框中所示。

英文:

You are correct that you want version 6 to go with NetCore 6. I feel this is not obvious. You can verify it by comparing the framework version highlighted at

With the next version up:

and see that SignalR.Client version 6 supports net6, whereas Client version 7 supports net7.

(And, on the dependencies tab, you can see that version 7 will drag in AspNet 7 dependencies)

Serverside

There is no serverside package because it is included in AspNetCore, per the top-right box in the first table on https://learn.microsoft.com/en-us/aspnet/core/signalr/version-differences?view=aspnetcore-6.0

huangapple
  • 本文由 发表于 2023年3月12日 06:44:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75710038.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定