jeudi 4 novembre 2021

How to retrieve Controller methods from WebApi binaries?

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."));

... 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.

Thank you for your help,





Aucun commentaire:

Enregistrer un commentaire