google-api-dotnet-client: GetFallbackPolicyAsync does not have an implementation

Using dotnet core version 3 (Preview 7) results in the error

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types.
Method 'GetFallbackPolicyAsync' in type 'Google.Apis.Auth.AspNetCore.GoogleScopedPolicyProvider' from assembly 'Google.Apis.Auth.AspNetCore, Version=1.40.2.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' does not have an implementation.'

What I am trying to do is pull back blog posts first, and then I want to integrate with some other APIs. I do have the latest Google.Apis libraries from NuGet. It was working with 3.0 Preview 5, but ASP.NET core has a new @code that is replacing @function in razor pages.

The full trace is

   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.get_Types()
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFeatureProvider.PopulateFeature(IEnumerable`1 parts, ControllerFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetControllerTypes()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
   at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
   at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken()
   at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.<>c__DisplayClass11_0.<Subscribe>b__0()
   at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe()
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionEndpointDataSource..ctor(IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.EnsureRazorPagesServices(IEndpointRouteBuilder endpoints)
   at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.MapFallbackToPage(IEndpointRouteBuilder endpoints, String page)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 26 (4 by maintainers)

Commits related to this issue

Most upvoted comments

@chrisdunelm Any updates on this? we are pretty blocked with .net core 3.0 migrations, and .net core 2.2 is touching the “End Of Life” in 2 weeks (23/12/19)

@jmmccota: Yes, as per the previous comments, use the new Google.Apis.Auth.AspNetCore3 package.

@KuzonCode: Yes, there’s a beta of the new package: https://www.nuget.org/packages/Google.Apis.Auth.AspNetCore3/1.43.0-beta01 Sorry that we hadn’t put that in this issue!

We’ve got quite a bit of work to do on fixing integration tests, then preparing the new ASP.NET3.0 package. I’m fairly sure we now intend to do this work, but this won’t be immediate. I would expect by early/mid-November we might have a beta package ready. This issue will be updated with progress.

I’ve been looking into this today, and I suspect we’re going to have to have two separate packages, i.e. introduce Google.Apis.Auth.AspNetCore3 or something similar. While I’ve managed to tease the current code into implementing the interface for GetFallbackPolicyAsync, there are issues due to the dependencies on 2.x assemblies. A clean break to AspNetCore3 is likely to be simpler. Will try that this afternoon and keep updating the issue with progress.

I’m sorry that we haven’t had time to work on this. It’s possible that we could just call GetFallbackPolicyAsync on our default policy provider. With so little documentation provided, however, it’s not clear whether that’s actually the correct thing to do. While we’d definitely like to get this working with 3.0, we have other higher priorities at the moment.

What we might be able to do is create a beta release which just delegates to the default policy provider, and let users try that at their own risk. Note that even that will take a bit of work as we’ll need to have a 3.0 target in order to call GetFallbackPolicyAsync on our default provider 😦 I’ll talk with @chrisdunelm about how to proceed; feedback about whether a speculative beta makes sense would be welcome.

Returning null seems to cause problems. I’m migrating from 2.2 to 3.0 preview 8 and I had to implement the interface for our custom IAuthorizationPolicyProvider. First implementation was this:

    public Task<AuthorizationPolicy> GetFallbackPolicyAsync()
    {
        return null;
    }

But:

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.AspNetCore.Authorization.AuthorizationPolicy.CombineAsync(IAuthorizationPolicyProvider policyProvider, IEnumerable1 authorizeData) at Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter.GetEffectivePolicyAsync(AuthorizationFilterContext context) at Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter.OnAuthorizationAsync(AuthorizationFilterContext context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at NSwag.AspNetCore.Middlewares.SwaggerUiIndexMiddleware1.Invoke(HttpContext context) at NSwag.AspNetCore.Middlewares.RedirectToIndexMiddleware.Invoke(HttpContext context) at NSwag.AspNetCore.Middlewares.SwaggerDocumentMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.SetRoutingAndContinue(HttpContext httpContext) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

I changed the implementation to the following and got past the Object reference not set to an instance of an object:

    public Task<AuthorizationPolicy> GetFallbackPolicyAsync()
    {
        var result = new AuthorizationPolicyBuilder();
        result = result.RequireAssertion(context =>
        {
            return true;
        });

        return Task.FromResult(result.Build());
    }

I am running into this issue, is there any progress?

This bug is the only reason why I can’t yet upgrade to 3.0. Is there an ETA?

Hi there, it’s been a while. Is there something I can do on my end to fix this? I would like to be able to use the Google Api again without having to drop back to 2.x.