Open HamidMusayev opened 1 year ago
Update: Moving refit interfaces to another project inside solution fixes the bug
Update: Moving refit interfaces to another project inside solution fixes the bug
@HamidMusayev could you please explain further what made it work? I have the same issue and wonder what the requirement is for the project that should contain the interfaces?
I had this issue when using Scrutor.
If you are registering dependencies by automatically scanning the assembly, be sure to exclude your refit interface, in your case IPetStoreClient
.
Potential cause: .net will validate the dependencies registered can be resolved on application start, meaning your refit interfaces (like IRequestBuilder) have no implementations registered, causing the above exception.
I had this issue when using Scrutor.
Yes, we're using Scrutor too.
Refit.IRequestBuilder dependency injection exception 🐞
Interface
Exception An unhandled exception of type 'System.AggregateException' occurred in Microsoft.Extensions.DependencyInjection.dll: 'Some services are not able to be constructed' Inner exceptions found, see $exception in variables window for more details. Innermost exception System.InvalidOperationException : Unable to resolve service for type 'Refit.IRequestBuilder' while attempting to activate 'Refit.Implementation.Generated+BLLExternalClientsIPetStoreClient'.
Injection
Usage
Note 1 Same error when creating inside constructor
Note 2 Same error when creating instance
Step to reproduce
Refit.HttpClientFactory v7.0.0 Refit v7.0.0
Reproduction repository
https://github.com/reactiveui/refit
Expected behavior
Dependency injection IRequestBuilder exception
Screenshots 🖼️
No response
IDE
Visual Studio 2022, Rider Windows, Visual Studio Code
Operating system
Windows
Version
No response
Device
No response
Refit Version
7.0.0
Additional information ℹ️
null