Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultServiceActivator<T> is not using custom IServiceProvider #2530

Open
DavidHoechtlJH opened this issue Sep 9, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@DavidHoechtlJH
Copy link

What version of gRPC and what language are you using?

2.65.0

What operating system (Linux, Windows,...) and version?

Windows

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

.NET SDK:
Version: 8.0.400

What did you do?

I register my custom IServiceProvider in my Asp.NetCore Kestrel server via:

webApplicationBuilder.Host.UseServiceProviderFactory( new MyCustomServiceProvider( Container ) );
// Container is a Autofac IContainer instance
(i´m using a hybrid system that combines the microsoft dependency container with a built Autofac.Container)

What did you expect to see?

DefaultServiceActivator should us the MyCustomServiceProvider to resolve grpc services

What did you see instead?

DefaultServiceActivator uses a different instance of IServiceProvider (looks like the default microsoft dependency IServiceProvider)

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
on service creation i´m getting following exception:

System.InvalidOperationException: Unable to resolve service for type 'MyService' while attempting to activate 'OtherService'. at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ThrowHelperUnableToResolveService(Type type, Type requiredBy) at lambda_method4900(Closure, IServiceProvider, Object[]) at Grpc.AspNetCore.Server.Internal.DefaultGrpcServiceActivator1.Create(IServiceProvider serviceProvider) at Grpc.Shared.Server.UnaryServerMethodInvoker3.Invoke(HttpContext httpContext, ServerCallContext serverCallContext, TRequest request) --- End of stack trace from previous location --- at Grpc.AspNetCore.Server.Internal.CallHandlers.UnaryServerCallHandler3.HandleCallAsyncCore(HttpContext httpContext, HttpContextServerCallContext serverCallContext) at Grpc.AspNetCore.Server.Internal.CallHandlers.ServerCallHandlerBase3.<HandleCallAsync>g__AwaitHandleCall|8_0(HttpContextServerCallContext serverCallContext, Method2 method, Task handleCall)

@DavidHoechtlJH DavidHoechtlJH added the bug Something isn't working label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant