首页 > 解决方案 > SignalR 客户端在释放模式 (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);

标签: c#uwpsignalrsignalr.client

解决方案


我这样解决:将命名空间添加到 Default.rd.xml 中的指令

<Namespace Name="System.Text.Json" Dynamic="Required All" />

推荐阅读