如何在类库项目中使用Signalr Hub类? 我没有看到可能对 Hub 的引用。
如何在Application项目中访问它?
应用程序csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bidnest.Persistance\Bidnest.Persistance.csproj" />
</ItemGroup>
</Project>
如果我们需要在
Class Library (.net core)
项目中定义signalr hub,我们必须安装Microsoft.AspNetCore.SignalR.Core
包。
众所周知,asp.net Core SignalR 包已默认集成到 asp.net Core 7/8 Web 应用程序中。
所以如果我们想在
Class Library
中使用它,我们必须手动安装它。
我之前写过一个repo,这里是你可以参考的链接https://github.com/Jason446620/AspNetCore7。