Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem using AutoRepositoryTypes #968

Closed
thiagoburgo opened this issue Apr 6, 2016 · 6 comments
Closed

Problem using AutoRepositoryTypes #968

thiagoburgo opened this issue Apr 6, 2016 · 6 comments

Comments

@thiagoburgo
Copy link

Hi @hikalkan,

Me again :)!

I trying use AutoRepositoryTypes annotation in my DbContext, but when I do it, get an exeption:

Code:

 [AutoRepositoryTypes(
           typeof(IRepository<>),
           typeof(IRepository<,>),
           typeof(ClinAppsRepositoryBase<>),
           typeof(ClinAppsRepositoryBase<,>)
           )]
    public class ClinAppsDbContext : AbpZeroDbContext<Tenant, Role, User>
    {

Exception:

Erro de Servidor no Aplicativo '/ClinSite'.

Can not instantiate proxy of class: Clintech.ClinApps.Repositories.Repositories.ClinAppsRepositoryBase`1[[Abp.Localization.ApplicationLanguage, Abp.Zero, Version=0.8.3.0, Culture=neutral, PublicKeyToken=null]].
Could not find a parameterless constructor.

Descrição: Ocorreu uma exceção sem tratamento durante a execução da atual solicitação da Web. Examine o rastreamento de pilha para obter mais informações sobre o erro e onde foi originado no código. 

Detalhes da Exceção: Castle.DynamicProxy.InvalidProxyConstructorArgumentsException: Can not instantiate proxy of class: Clintech.ClinApps.Repositories.Repositories.ClinAppsRepositoryBase`1[[Abp.Localization.ApplicationLanguage, Abp.Zero, Version=0.8.3.0, Culture=neutral, PublicKeyToken=null]].
Could not find a parameterless constructor.

Erro de Origem: 


Linha 10:         {
Linha 11:             AbpBootstrapper.IocManager.IocContainer.AddFacility<LoggingFacility>(f => f.UseLog4Net().WithConfig("log4net.config"));
Linha 12:             base.Application_Start(sender, e);
Linha 13:         }
Linha 14:     }

Arquivo de Origem: D:\Projetos\Pessoal\Consultoria Ortoclin\ClinApps\Source\Develop\Clintech.ClinApps\Clintech.ClinApps.ClinSite\Global.asax.cs    Linha: 12 

Rastreamento de Pilha: 


[InvalidProxyConstructorArgumentsException: Can not instantiate proxy of class: Clintech.ClinApps.Repositories.Repositories.ClinAppsRepositoryBase`1[[Abp.Localization.ApplicationLanguage, Abp.Zero, Version=0.8.3.0, Culture=neutral, PublicKeyToken=null]].
Could not find a parameterless constructor.]
   Castle.DynamicProxy.ProxyGenerator.CreateClassProxyInstance(Type proxyType, List`1 proxyArguments, Type classToProxy, Object[] constructorArguments) +352
   Castle.Windsor.Proxy.DefaultProxyFactory.Create(IKernel kernel, Object target, ComponentModel model, CreationContext context, Object[] constructorArguments) +707
   Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments) +366

I changed module-zero template structure, basically separating interfaces from implementation in different projects. If you need see my project: https://github.com/thiagoburgo/abp-initial-sample

Thanks,

@thiagoburgo thiagoburgo changed the title Use of Problem using AutoRepositoryTypes Apr 7, 2016
@hikalkan
Copy link
Member

hikalkan commented Apr 7, 2016

Hi :)

Unfortunately, I could not understood the reason. Is it working if you remove AutoRepositoryTypes?

@thiagoburgo
Copy link
Author

Yes, if I remove AutoRepositoryTypes attribute, my application executes without problems, but I can't inject IRepository, you can see code commented in constructor https://github.com/thiagoburgo/abp-initial-sample/blob/master/Clintech.ClinApps/Clintech.ClinApps.Domain.Impl/Services/S4/PessoaService.cs#L13

Thanks,

@prateek14
Copy link

prateek14 commented Jun 1, 2017

any fixes for this? or workarounds

@prateek14
Copy link

nevermind, figured out the issue
constructor was protected

@sebfischer83
Copy link

@prateek14 Can you please explain how you resolve this issue?

@hawkpgl
Copy link

hawkpgl commented Apr 6, 2018

@prateek14 just saved me a lot of time. When inheriting from RepositoryBase, if you resolve the constructor, it gets created as protected. Thanks for leaving your comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants