c# - Ninject 3.2 BindFilter constructor binding broken when using Ninject.Extension.Factory 3.2 -
i have mvc5, webapi application works fine if don't include ninject.extension.factory 3.2.0.0 3/21/2014 build. once add package application has following exception:
error activating entitleactionfilter using self-binding of entitleactionfilter several constructors have same priority. please specify constructor using toconstructor syntax or add inject attribute. constructors: entitleactionfilter(list{navigationitem} navigationitemsfunc{ienumerable{string}} permissionfunc) entitleactionfilter(list{navigationitem} navigationitemsfunc{ienumerable{int}} permissionfuncint)
i'm using following ninject packages (all friday, 3/21/2014 builds):
- ninject 3.2.0.0
- ninject.mvc5 3.2.0.0
- ninject.web.common 3.2.0.0
- ninject.web.common.webhost 3.2.0.0
those 2 constructors unique. bindings like:
func<ienumerable<int>> permissionfunc = () => kernel.get<inavigationpermissionsprovider>().getpermissionsint(); this.bindfilter<entitleactionfilter>(filterscope.controller, 0) .withconstructorargument("navigationitems", context => context.get<navigationhelper>().getnavigation().navigationitems) .withconstructorargument("permissionfuncint", permissionfunc);
i use ninject factories lot , need package. if remove ninject.extensions.factory 3.2 package, works. same code worked previous 3.0 version of ninject , factory extension.
this not related factory extension. factory extension adds bindings func overloads means both constructors can satisfied completely.
with ninject 3.0 of constructor chosen if there several same priority. there no guarantee same 1 picked. 1 picked decided implementation of .net framework functions give no guarantee ordering. in worst case means .net framework version decides constructor picked.
ninject 3.2 throws exception if there several constructors same priority have configure constructor taken, correct 1 picked.
if wouldn't use func dependency instead inject instance of inavigationpermissionsprovider
, call getpermissionsint()
Comments
Post a Comment