我猜,你的问题是这样的:
GlobalHost.DependencyResolver.Register(typeof(JsonSerializer),() => JsonSerializerFactory.Value);
如果您使用Autofac作为容器/依赖解析器,你要注册与Autofac序列化,不能与即将TO-被替换的全局依赖解析器。
builder.Register(ctx => JsonSerializerFactory.Value).As<JsonSerializer>();
此外,我看到你正在使用OWIN。当您使用OWIN时,您不会引用GlobalHost
- 您分别设置了集线器配置。 The docs have an example showing how to do it:
public class Startup
{
public void Configuration(IAppBuilder app)
{
var builder = new ContainerBuilder();
// STANDARD SIGNALR SETUP:
// Get your HubConfiguration. In OWIN, you'll create one
// rather than using GlobalHost.
var config = new HubConfiguration();
// Register your SignalR hubs.
builder.RegisterHubs(Assembly.GetExecutingAssembly());
// Set the dependency resolver to be Autofac.
var container = builder.Build();
config.Resolver = new AutofacDependencyResolver(container);
// OWIN SIGNALR SETUP:
// Register the Autofac middleware FIRST, then the standard SignalR middleware.
app.UseAutofacMiddleware(container);
app.MapSignalR("/signalr", config);
}
}
谢谢,可能需要几天时间我才能检查结果并标记为正确。我知道这将与全局主机有关,只是不确定注册该串行器的语法。 – MrBliz
这对我不起作用。它注册一切正常,但串行器似乎搞乱了通信。一旦我有了序列化程序,来自主机的消息就不会再向客户端发送消息了。 @MrBliz你能分享一下你是否有这个固定的? – Jasper
我没有。我结束了客户端上的pascal套件 – MrBliz