'Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.
这个问题如果我ctrl+f5就没有,部署到iis就会出现,f5调试也会报这个错误,
有没有大神能分析下哪里的问题
Code部分代码,调用一下SignalR
····
@using Microsoft.AspNetCore.SignalR.Client
@using My.Share.Models
@inject NavigationManager NavigationManager
@code {
private HubConnection hubConnection;
private List<string> messages = new List<string>();
List<Side> Sides = new List<Side>();
protected async override Task OnInitializedAsync()
{
try
{
hubConnection = new HubConnectionBuilder()
.WithUrl("http://192.168.0.115:7788/myhub")
.Build();
hubConnection.On("Register", (string type, string id) =>
{
Sides.Add(new Side() { Id = id, Type = type, State = "上线" });
//messages.Add($"管理端({data}) 上线");
Sides = Sides.OrderBy(t => t.State).ToList();
StateHasChanged();
});
hubConnection.On("UnRegister", (string data) =>
{
var side = Sides.FirstOrDefault(t => t.Id.Equals(data));
if (side != null)
{
side.State = "下线";
}
Sides = Sides.OrderBy(t => t.State).ToList();
//messages.Add($"管理端({data}) has UnRegister");
StateHasChanged();
});
await hubConnection.StartAsync();
hubConnection.SendAsync("Register","管理").Wait();
}
catch (Exception ex) { Console.WriteLine("Herehere" + Environment.NewLine + ex.Message); }
}
····
Client是在Program这么注册的:
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri("http://192.168.0.115:7788") });
代码没问题的,清空bin,清理下工程再重新发布就可以了。
别问我怎么晓得这样处理的,我都准备去提交issue了,兄弟你不是一个人,。