Base solution for your next web application
Open Closed

logger get's not properly instantiated #1193


User avatar
0
patrickglaudemans created

Hi,

I'm using setup like mentioned in earlier discussion:

(RE: ACCESSING ZERO APPLICATION LAYER FROM EXTERNAL CLASSLIB #5732 We have a Console Application to demonstrate it: <a class="postlink" href="https://github.com/aspnetzero/aspnet-ze">https://github.com/aspnetzero/aspnet-ze</a> ... ConsoleApp)

When accessing the logger (setup via: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Logging">http://www.aspnetboilerplate.com/Pages/ ... ts/Logging</a>) I get error below: "Could not find a public constructor for type Abp.Authorization.NullPermissionChecker"

detailed error:

Castle.Windsor Warning: 0 : Exception when resolving optional dependency Dependency 'PermissionChecker' type 'Abp.Authorization.IPermissionChecker' on component Intertek.BI.Reporting.Reports.ReportAppService., Castle.MicroKernel.ComponentActivator.ComponentActivatorException: Could not find a public constructor for type Abp.Authorization.NullPermissionChecker.
Windsor by default cannot instantiate types that don't expose public constructors.
To expose the type as a service add public constructor, or use custom component activator.
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.FastCreateInstance(Type implType, Object[] arguments, ConstructorCandidate constructor)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstance(CreationContext context, ConstructorCandidate constructor, Object[] arguments)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden)
   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally)
   at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy)
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernelByType(CreationContext context, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveFromKernel(CreationContext context, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.ResolveCore(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver)
Castle.Windsor Warning: 0 : Exception when resolving optional dependency Dependency 'PermissionChecker' type 'Abp.Authorization.IPermissionChecker' on component Intertek.BI.Reporting.Reports.ReportAppService., Castle.MicroKernel.ComponentActivator.ComponentActivatorException: Could not find a public constructor for type Abp.Authorization.NullPermissionChecker.

2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Have you registered NullPermissionChecker to DI in your code? It should not be registered. Can you check it?

  • User Avatar
    0
    patrickglaudemans created

    Hi,

    Yep.

    namespace Intertek.BI.ApplicationService
    {
          [DependsOn(
            typeof(BIDataModule), 
            typeof(BIApplicationModule),
            typeof(BIReportingCoreModule)
            )]
        public class ApplicationServiceModule : AbpModule
        {
            public override void PreInitialize()
            {
                //Suppress authentication and permission checking for the console application
                IocManager.Register<IAbpSession, ApplicationServiceSession>();
                IocManager.Register<IPermissionChecker, NullPermissionChecker>();
            }
    
            public override void Initialize()
            {
                IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            }
        }
    
    }
    

    The error disappeared after having commented out the registration of that particular nul checker in above code! (strange?)

    But I fixed it by using log4net directly. It works better that way with Quartz common logging.

    Thanks anyway!