Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which SignalR package to install for a .NET 6 server project?

I have a NET6 project which is built part of a larger .NET 6 ASP.NET solution. The project still references:

  1. Microsoft.AspNetCore.SignalR, and
  2. Microsoft.AspNetCore.SignalR.Core

Which have now been marked as deprecated.

What packages do I need to install for their replacement?

The problem is that currently SignalR is located in an assembly separate from the main ASP.NET project. This is because the main project and a couple of other projects within the solution use the hubs (using constructor DI).

If I change the SignalR project to

<Project Sdk="Microsoft.NET.Sdk.Web">
    ...
</Project>

I get the following compilation error:

Error CS5001 Program does not contain a static 'Main' method suitable for an entry point

So the problem is that I cannot have a common assembly with SignalR referenced by multiple other projects.

like image 769
Ivan-Mark Debono Avatar asked Nov 28 '25 16:11

Ivan-Mark Debono


1 Answers

SignalR is included in the Microsoft.AspNetCore.App shared framework (docs). Change the console app SDK to Microsoft.NET.Sdk.Web:

<Project Sdk="Microsoft.NET.Sdk.Web">
   ...
</Project>

To use the ASP.NET Core shared framework in a class library project - add FrameworkReference element for Microsoft.AspNetCore.App:

<ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
like image 91
Guru Stron Avatar answered Dec 01 '25 08:12

Guru Stron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!