SignalR 客户端在发布模式 (UWP) 下不接收信号
SignalR Client doesn't receive signal in release mode (UWP)
我在我的 UWP 应用程序中使用 Microsoft.AspNetCore.SignalR.Client 3.1.1。我的代码在调试模式下工作正常,我的应用程序接收到信号,但是当我使用发布模式时,我的应用程序没有接收到信号。
我认为 VS 的编译器不包括某些方法或 类 或其他内容。我该如何解决?我的代码如下:
var hubConnectionToWebService = new HubConnectionBuilder().WithUrl($"{Setting.Instance.UrlSignalR_WebService}").WithAutomaticReconnect(new RandomRetryPolicy()).Build();
hubConnectionToWebService.On<int, string>("ReceiveMessage", async (categoryID, tags) =>
{
Setting.Instance.CurrentCategoryID = categoryID;
await ReplacementBanners();
});
await ConnectWithRetryAsync(hubConnectionToWebService, tokenClosingClient);
我是这样解决的:在 Default.rd.xml
中的指令中添加了命名空间
<Namespace Name="System.Text.Json" Dynamic="Required All" />
我在我的 UWP 应用程序中使用 Microsoft.AspNetCore.SignalR.Client 3.1.1。我的代码在调试模式下工作正常,我的应用程序接收到信号,但是当我使用发布模式时,我的应用程序没有接收到信号。 我认为 VS 的编译器不包括某些方法或 类 或其他内容。我该如何解决?我的代码如下:
var hubConnectionToWebService = new HubConnectionBuilder().WithUrl($"{Setting.Instance.UrlSignalR_WebService}").WithAutomaticReconnect(new RandomRetryPolicy()).Build();
hubConnectionToWebService.On<int, string>("ReceiveMessage", async (categoryID, tags) =>
{
Setting.Instance.CurrentCategoryID = categoryID;
await ReplacementBanners();
});
await ConnectWithRetryAsync(hubConnectionToWebService, tokenClosingClient);
我是这样解决的:在 Default.rd.xml
中的指令中添加了命名空间<Namespace Name="System.Text.Json" Dynamic="Required All" />