mercredi 15 novembre 2023

Assembly.GetTypes() throws ReflectionTypeLoadException because of a protected abstract method

I'm trying to dynamically load assemblies and get the types in them, but I'm running into this exception:

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. Method 'HandleAuthenticateAsync' in type 'My.Namespace.Api.Attributes.BasicAuthenticationHandler' from assembly 'My.Namespace.API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.'

This type inherits from the abstract class Microsoft.AspNetCore.Authentication.AuthenticationHandler, which has the abstract method: protected abstract Task<AuthenticateResult> HandleAuthenticateAsync();

I'm loading these assemblies from a separate dotnet 7 application - is there a way to load these assemblies in such a way that I can see non public types/fields/methods/etc through reflection? I also have access to the projects themselves, so I could build them with different settings if that's necessary.





Aucun commentaire:

Enregistrer un commentaire