system.aggregate Exception

'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BaseApi.Service.ItemService Lifetime: Scoped ImplementationType: BaseApi.Service.ItemService': Unable to resolve service for type 'BaseApi.Repository.ItemRepository' while attempting to activate 'BaseApi.Service.ItemService'.) (Error while validating the service descriptor 'ServiceType: BaseApi.Service.PostService Lifetime: Scoped ImplementationType: BaseApi.Service.PostService': Unable to resolve service for type 'BaseApi.Repository.PostRepository' while attempting to activate 'BaseApi.Service.PostService'.) (Error while validating the service descriptor 'ServiceType: BaseApi.Service.UserService Lifetime: Scoped ImplementationType: BaseApi.Service.UserService': Unable to resolve service for type 'BaseApi.Repository.UserRepository' while attempting to activate 'BaseApi.Service.UserService'.)'
'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BaseApi.Service.ItemService Lifetime: Scoped ImplementationType: BaseApi.Service.ItemService': Unable to resolve service for type 'BaseApi.Repository.ItemRepository' while attempting to activate 'BaseApi.Service.ItemService'.) (Error while validating the service descriptor 'ServiceType: BaseApi.Service.PostService Lifetime: Scoped ImplementationType: BaseApi.Service.PostService': Unable to resolve service for type 'BaseApi.Repository.PostRepository' while attempting to activate 'BaseApi.Service.PostService'.) (Error while validating the service descriptor 'ServiceType: BaseApi.Service.UserService Lifetime: Scoped ImplementationType: BaseApi.Service.UserService': Unable to resolve service for type 'BaseApi.Repository.UserRepository' while attempting to activate 'BaseApi.Service.UserService'.)'
but I registered my all services and repos
No description
15 Replies
only you know
only you knowOP9mo ago
an example of one of my service
No description
only you know
only you knowOP9mo ago
also repo
No description
Pobiega
Pobiega9mo ago
First: Please name your thread better. AggregateException literally just means "one or more exceptions" second: You are registering your repos as their interface, but injecting the concrete repository inject the interface instead
only you know
only you knowOP9mo ago
thank you for your help I fixed it @Pobiega can you tell me why I cant inject ItemRepos in to ItemService? I have method in itemrepos but don't have in irepo interface and I want to use that method in service
Pobiega
Pobiega9mo ago
Then you are breaking the entire purpose of having an interface there in the first place and also your rest of your program is now tightly coupled to your MongoDB implementation of the repository is that really what you want? in that case, just register the repository without the interface
only you know
only you knowOP9mo ago
no that's not I want. I'll keep have generic interface to minimalize my program to mongo
Pobiega
Pobiega9mo ago
okay, then add your method to the interface
only you know
only you knowOP9mo ago
oki doki if I share my codes in code-review can you review it in general and share your thought and encounters? In that way I can understand my mistakes better and also I can learn that what should I improve.
Pobiega
Pobiega9mo ago
sure.
only you know
only you knowOP9mo ago
can you also tell me what's the problem I show the directory of program as existing repo but I can't commit my changes
No description
only you know
only you knowOP9mo ago
should I create a new one
Pobiega
Pobiega9mo ago
Have absolutely no idea what that is Doesn't look like VS. Is it vs code? But the error is pretty clear, it can't access that file due to permissions I'd shut down the ide entirely and delete the .vs folder
only you know
only you knowOP9mo ago
yes. I think I should exclude vs files someone fixed this problem with this solution but couldn't find it on visual studio
Pobiega
Pobiega9mo ago
Oh yeah you should not be pushing .Vs folder to git Get a gitignore file dotnet new gitignore is good
only you know
only you knowOP9mo ago
fixed thank you
Want results from more Discord servers?
Add your server