如何从 WebApi 二进制文件中检索控制器方法? [英] How to retrieve Controller methods from WebApi binaries?
问题描述
我已经编译并发布了 API (ASP.NET Core WebAPI
on `.NET5).我想从另一个桌面应用程序 (WPF) 中检索 Controller 类中的方法列表.在之前的 .NET 版本中,我是这样做的:
I have already compiled and published API (ASP.NET Core WebAPI
on `.NET5). I would like to retrieve a list of methods in Controller classes, from another Desktop application (WPF). In prior .NET versions I was doing it this way:
Assembly assembly = Assembly.LoadFrom(assemblyPath);
var types = assembly.GetExportedTypes().Where(a => a.FullName != null && a.FullName.StartsWith("MyTestApp.WebApi.Controllers."));
...但这在 .NET5
中不起作用,因为由于某种原因,在 .NET5
中构建/发布项目时没有复制所有必需的 dll.所以我正在寻找一种直接的方法来获取给定命名空间中的方法列表.
... but that doesn't work in .NET5
because for some reason no all required dlls are copied when building/publishing the project in .NET5
. So I'm looking for a straight forward way to just get list of methods in a given namespaces.
感谢您的帮助,
推荐答案
将你的 .dll 程序集放入 ILSpy 或类似的东西,然后反编译它们?
Throw your .dll assemblies in ILSpy or something similar and just decompile them?
这篇关于如何从 WebApi 二进制文件中检索控制器方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!