Custom Repository
See original GitHub issueHi,
I cannot make custom repository work, please help:
I try to make OneRepositoryBase the reference repository but it always fails at startup, see attached project. MyProject.zip
here is the error:
An error occurred while starting the application. ArgumentException: Target does not implement interface Abp.Domain.Repositories.IRepository
1[[Abp.Localization.ApplicationLanguage, Abp.Zero.Common, Version=3.6.1.0, Culture=neutral, PublicKeyToken=null]] Parameter name: target Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, object target, ProxyGenerationOptions options, IInterceptor[] interceptors) ComponentActivatorException: ComponentActivator: could not proxy MyProject.EntityFrameworkCore.MainRepository
1[[Abp.Localization.ApplicationLanguage, Abp.Zero.Common, Version=3.6.1.0, Culture=neutral, PublicKeyToken=null]] Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments) ArgumentException: Target does not implement interface Abp.Domain.Repositories.IRepository`1[[Abp.Localization.ApplicationLanguage, Abp.Zero.Common, Version=3.6.1.0, Culture=neutral, PublicKeyToken=null]] Parameter name: target Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, object target, ProxyGenerationOptions options, IInterceptor[] interceptors) Castle.Windsor.Proxy.DefaultProxyFactory.Create(IKernel kernel, object target, ComponentModel model, CreationContext context, Object[] constructorArguments) Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)
related to #2280, but I used the template
- Your Abp package version: 3.6.1
- Your base framework: .Net Core.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
You’re welcome. I submitted a PR to make
RepositoryBase
implementIRepository<TEntity>
. Theabstract
declaration is intended for developers to create (multiple) concrete subclasses.My apologies, you was right. Somehow the template was created with some mistakes.
protected abstract class ProvizoCoreRepositoryBase<TEntity> : ProvizoCoreRepositoryBase<TEntity, int> where TEntity : class, IEntity<int> { protected ProvizoCoreRepositoryBase(IDbContextProvider<ProvizoCoreDbContext> dbContextProvider) : base(dbContextProvider) { } }
As you said all the time, it should be like:
public class ProvizoCoreRepositoryBase<TEntity> : ProvizoCoreRepositoryBase<TEntity, int>, IRepository<TEntity> where TEntity : class, IEntity<int> { public ProvizoCoreRepositoryBase(IDbContextProvider<ProvizoCoreDbContext> dbContextProvider) : base(dbContextProvider) { } }
Thank you for your time, and my apologies one more time.