如何加载DLL并将路由URL分配给方法以将其用作WebAPI调用?

发布于 2025-02-13 05:11:03 字数 271 浏览 2 评论 0原文

我正在用ASP.NET核心编写一个应用程序,其中包含一组WebAPI定义的USIG MVC和路由属性。 现在,我想管理添加功能,但是作为一个插件,我将在外部DLL中定义它们,然后加载它

Assembly assemblyPlugin = Assembly.LoadFrom(DLL2load);

是可以的,但是我如何能够从Anotther应用程序中将其方法称为WebAPI? 我是否可以在加载的DLL内定义其路由属性,或在将其加载到主应用程序中后分配?我该怎么做?

i'm writing an application in asp.net core with a set of webAPI defined usig MVC and routing attributes.
Now i'd like to manage additionals functions but, as a plugin, i'm going to define them in a external DLL and then load it with

Assembly assemblyPlugin = Assembly.LoadFrom(DLL2load);

This is ok but how can i be able to call its methods as webAPI from anotther application ?
May i have to define their routing attributes inside the loaded DLL or to assign them after loading it in the main application? How can i do it ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放飞的风筝 2025-02-20 05:11:03

您可以做以下操作,

services.AddControllers() // use AddControllersWithViews for MVC app
        .AddApplicationPart(Assembly.Load(new AssemblyName("DlltoLoad")));

you can do following,

services.AddControllers() // use AddControllersWithViews for MVC app
        .AddApplicationPart(Assembly.Load(new AssemblyName("DlltoLoad")));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文