RestEase.HttpClientFactory .NET5 does not seem to register my typed client.
See original GitHub issueError
❯ dotnet run
Building...
Unhandled exception. System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostedService Lifetime: Singleton ImplementationType: RestEaseWorker.Worker': Unable to resolve service for type 'RestEaseWorker.IPersonAPI' while attempting to activate 'RestEaseWorker.Worker'.)
---> System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostedService Lifetime: Singleton ImplementationType: RestEaseWorker.Worker': Unable to resolve service for type 'RestEaseWorker.IPersonAPI' while attempting to activate 'RestEaseWorker.Worker'.
---> System.InvalidOperationException: Unable to resolve service for type 'RestEaseWorker.IPersonAPI' while attempting to activate 'RestEaseWorker.Worker'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(ServiceDescriptor serviceDescriptor, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
--- End of inner exception stack trace ---
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(ServiceDescriptor descriptor)
at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable`1 serviceDescriptors, IServiceProviderEngine engine, ServiceProviderOptions options)
--- End of inner exception stack trace ---
at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable`1 serviceDescriptors, IServiceProviderEngine engine, ServiceProviderOptions options)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter`1.CreateServiceProvider(Object containerBuilder)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at RestEaseWorker.Program.Main(String[] args) in C:\Users\Desktop\RestEaseWorker\Program.cs:line 15
I am sure I am missing something silly, but I followed the directions here: https://github.com/canton7/RestEase#using-httpclientfactory
Repro: https://github.com/VictorioBerra/restease-httpclientfactory-issue
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
c# - HttpClientFactory and typed-client?
1 Answer. In Typed-Client, Dotnet uses HttpClientFactory to create the instance of HttpClient , using that instance they will create your ...
Read more >canton7/RestEase: Easy-to-use typesafe REST API client ...
Easy-to-use typesafe REST API client library for .NET Standard 1.1 and .NET Framework 4.5 and higher, which is simple and customisable.
Read more >Creating and Using HTTP Client SDKs in .NET 6 - InfoQ
In this article, the author explains the process behind developing HTTP Client SDKs in .NET 6. The article also contains a sample SDK ......
Read more >Make HTTP requests using IHttpClientFactory in ASP.NET ...
The typed client is registered as transient with DI. In the preceding code, AddHttpClient registers GitHubService as a transient service.
Read more >IHttpClientFactory Patterns: Using Typed Clients from ...
When defining typed clients in your ConfigureServices method, the typed service is registered with transient scope. This means that a new ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should be fixed in 1.5.2
Ah, misread the title, my bad