Hi
I am getting the following error during run-time when trying to invoke a method on ***AppService
, which is contained in a separate, well-contained module that is separate from my generated solution modules.
The module consists of several sub-modules, with proper dependencies set up between them
I have also done the following in terms of module dependencies:
- Added a module dependency from my module core to
AbpZeroCommonModule
- Added the required module dependencies from my base solution
Web.Core
solution to the custom modules. (All app services from the module runs successfully, except this specific one)
Can't create component '***AppService' as it has dependencies to be satisfied.
'***AppService' is waiting for the following dependencies:
- Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.AbpUserBase, Abp.Zero.Common, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
Castle.MicroKernel.Handlers.HandlerException: Can't create component '***AppService' as it has dependencies to be satisfied.
'***AppService' is waiting for the following dependencies:
- Service 'Abp.Domain.Repositories.IRepository`2[[Abp.Authorization.Users.AbpUserBase, Abp.Zero.Common, Version=4.4.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
Here is the redacted code for the affected applicationservice:
Please help - what am I missing here?
6 Answer(s)
-
0
It's
IRepository<User, long>
. -
0
Thanks for the feedback.
This wil work as a temporary quickfix, but is wrong insofar as clean coding principles.
- Creates an explicit dependency on a concrete class
- Tightly couples my module to my base solution (The
User
class is generated as part of your base solution and inherits fromAbpUserBase
).
I am trying to do custom / direct registration as per the official dependency injection documentation, but without success.
-
0
You are mistaken. All generic repositories use concrete classes. You can register
IUserRepository
similar to that documentation. -
0
I'm not mistaken. I know the generic repository pattern. I'm talking about clean coding (SOLID) practices.
-
0
Hi @mightyit
If you are only going to get records from AbpUsers table, you can create an interface as @aaron suggested named IUserRepository and work with AbpUserBase class in that repository. In that way, you can't create or update user records.
Second option would be moving User entity to a shared class library project and use it from your module and AspNet Zero app.
-
0
Hi @ismcagdas
I have implemented the temporary workaround but have came to the same conclusion as your second suggestion - that a shared library for authentication and authorization should be created. Perhaps something to consider for future versions of the boilerplate solution (if I may suggest)?