DryIoc无法解析我的布尔实例?

时间:2016-05-04 09:04:49

标签: dryioc

我尝试注册一个类,构造函数需要一些字符串,一个ILog和一个bool。我的容器中的所有内容都注册为单例(设置为默认重用)。

但每当我尝试获取该类container.Resolve<AzmanAccess>()的实例时,都会抛出异常。

  

无法将布尔值解析为参数“accessAll”   Company.Common.Util.Authentication.AzmanAccess:   Company.Common.Util.Authentication.IAzmanAccess   {RequiredServiceType = Company.Common.Util.Authentication.AzmanAccess}   作为参数“azmanAccess”in   Company.Common.Util.Authentication.AzmanCustomAccess:   Company.Common.Util.Authentication.IAccess作为参数“access”in   Company.Common.Util.Authentication.User:   Company.Common.Util.Authentication.IUser其中CurrentScope:null和   ResolutionScope:null和Found注册:skipAuthz,{ID = 53,   ImplType = Boolean,Reuse = SingletonReuse {Lifespan = 1000}}}   System.Object,{ID = 25,ImplType = Boolean,Reuse = SingletonReuse   {寿命= 1000}}}

我这样注册我的课程:

        container.RegisterInstance(_accessAll, serviceKey: AccessAll);
        container.RegisterInstance(_activeDirectoryDomain, serviceKey: ActiveDirectoryDomain);
        container.RegisterInstance(_azmanConnString, serviceKey: AzmanConnString);
        container.RegisterInstance(_azmanStore, serviceKey: AzmanStore);
        container.Register(Made.Of(() => new AzmanAccess(
                Arg.Of<bool>(AccessAll),
                Arg.Of<ILog>(),
                Arg.Of<string>(ActiveDirectoryDomain),
                Arg.Of<string>(AzmanConnString),
                Arg.Of<string>(AzmanStore)
            )));

,构造函数是:

    public AzmanAccess(bool accessAll, ILog logger, string activeDirectoryDomain, string azmanConnString, string azmanStore)

其中servicekeys(AccessAll,...)是唯一的(尝试使用对象,然后是字符串)。

出了什么问题?

1 个答案:

答案 0 :(得分:1)

the bug in DryIoc引起的问题:Arg.Of无法识别非基本类型的服务密钥。

在修复错误之前,解决方法是将object服务密钥更改为例如stringEnum typeint

<强>更新 该修复程序位于DryIoc v2.4.3