SignalR不会为传入的服务器调用解析JsonSerializer [英] SignalR don't resolve JsonSerializer for incoming server call

查看:266
本文介绍了SignalR不会为传入的服务器调用解析JsonSerializer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JRawValue( https: //github.com/SignalR/SignalR/blob/master/src/Microsoft.AspNet.SignalR.Core/Json/JRawValue.cs )使用:

JRawValue(https://github.com/SignalR/SignalR/blob/master/src/Microsoft.AspNet.SignalR.Core/Json/JRawValue.cs) using:

var serializer = JsonUtility.CreateDefaultSerializer();

为什么不呢?

var serializer = GlobalHost.DependencyResolver.Resolve<JsonSerializer>();

是虫子吗?

JsonSerializer serializer = JsonSerializer.Create(settings);
serializer.Converters.Add(new SomeConverter());
GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);

SomeConverter不适用于传入的服务器调用.

SomeConverter don't work for incoming server call.

推荐答案

如您所述,这是JRawValue中的错误.在GitHub上已经有一个针对此的问题:

As you noted, this is a bug in JRawValue. There is already an issue filed for this on GitHub here:

https://github.com/SignalR/SignalR/issues/3304

问题的提交者能够通过提供他们自己的DefaultParameterResolver来解决此问题,该问题使用反射来获取原始JSON字符串.

The submitter of the issue was able to work around it by providing their own DefaultParameterResolver that used reflection to get at the raw JSON string.

很不幸,这是必要的.如果需要,您可以在此问题上发表评论,表明对您来说解决此问题很重要.这将增加在即将发布的SignalR中修复该错误的可能性.

It's obviously pretty unfortunate that this is necessary. If you want, you can leave a comment on this issue indicating that it is important to you to see this issue fixed. This will increase the likelihood that the bug will be fixed in an upcoming release of SignalR.

如果您对此问题发表评论,则留下评论详细说明您在服务器上使用的自定义(反序列化)设置以及在客户端上自定义序列化集线器参数的操作时,可能会有所帮助,

If you do comment on the issue, it might be helpful if you left comments detailing what custom (de)serialization settings you are using on the server and what you did on the client to customize how the Hub parameters are serialized,

这篇关于SignalR不会为传入的服务器调用解析JsonSerializer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆