asp.net - Using SignalR via reflection
问题描述
I am developing an asp.net core 3.1 application that loads up an assembly using Application Parts and reflection. This plugin assembly is also an asp.net core 3.1 application which is all working fine except it also has SignalR functionality within it. In the host application I have the service registered in Startup.cs like this:-
services.AddSignalR();
In the Configure method I would normally have something like this:-
endpoints.MapHub<MyHub>("/myHub");
But MyHub is a class from the plugin assembly. How can I map the hub when it could be of any type? I don't want to have this MyHub class in the host application, it can only be in the plugin application.
解决方案
在您的解决方案中,您可以创建.NET Core Library
引用主项目的新项目。
在库项目中,您可以添加此 Nuget 包:
Microsoft.AspNetCore.SignalR.Core
然后,从那里创建您的 Hub 类并从Startup
该类映射它。
推荐阅读
- php - 从 woocommerce 挂钩中的订单项获取类别 ID
- windows - 在 Windows 10 Ubuntu 子系统上使用 anaconda - cygpath (?)
- php - 如何在PHP中递归调用具有特定时间延迟的函数
- java - 在 Minecraft mod 中修改 .class 文件
- python - 在打印函数中格式化浮点数以四舍五入到小数点后两位
- sql-server - 删除第五个之后的所有内容,包括 / (更新表)
- python-3.x - 如何在pyspark中压缩两列?
- android - 输出流 #0:1 的自动编码器选择失败
- dart - 触发从小部件到状态对象的函数
- angular - 如何在 ionic3 中解析 Json.stringify()