Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:51:41+00:00 2026-06-17T07:51:41+00:00

I am using ninject.extensions.conventions to bind all implementations in a given assembly and tag

  • 0

I am using ninject.extensions.conventions to bind all implementations in a given assembly and tag them with the assembly name as the binding’s metadata. I can pull these items back out using a Get and supplying a func as standard.

What I would like to know is does this func apply to all children resolved also? My worry is that while my logic works now, if I add more bindings that satisfy any children more than once ninject will throw.

Code Sample:

_kernel.Bind(binder => binder.From(new[] { pathToAssembly })
                             .SelectAllClasses()
                             .BindAllInterfaces()
                             .Configure(binding => 
                                        binding.WithMetadata("context", 
                                                             assemblyName)));


 _kernel.Get<IRootDependency>
         (metadata => metadata.Get<IRootDependency>("context") == 
                                                   assemblyName);

// Bound from convention above.
RootDependencyBase: IRootDependency
{
  Public RootDependencyBase(IChildDependency Child) {};
}

// Bound using the convention above with the same MetaData Tag.
ChildDependencyFromSameAssembly : IChildDependency {}

// Bound using a differing convention and does not have the same MetaData tag.
ChildDependencyFromOtherAssembly : IChildDependency {}

Based on the above sample I know that IRootDependency will be resolved to the correct binding based on the metadata filter.

What I am looking to find out is is the following true.

This filter does not feed down the dependency chain. IChildDependency will throw an exception because although the binding specified MetaData it is not queried.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:51:42+00:00Added an answer on June 17, 2026 at 7:51 am

    Constraints are applyed to the root resolution only. In case you have multiple assemblies containing a child dependency you will get an exception.

    To get it work you have to add a condition to the bindings. E.g like this:

    .When(r => r.ParentContext == null || r.ParentContext.Binding.Metadata.Get<string>("context", null) == assemblyName)
    

    Or get the root request (request.ParentRequest until parentRequest is null) and apply the constraint

    .When(r => GetRootRequest(r).Constraint(r))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my MVC4 app I'm using Ninject.Extensions.Conventions to autobind all itnerfaces with their implementation
I have set up a NInject (using version 1.5) binding like this: Bind<ISessionFactory>().ToMethod<ISessionFactory>(ctx =>
I'm using Ninject.MVC3. private static void RegisterServices(IKernel kernel) { kernel.Bind<Repository>().To<Repository>(); } Registering them like
We're using Ninject for IOC. All of our Repository objects can (and should be)
I'm using Ninject 3.0.1.10 for dependency injection and want to use Ninject.Extensions.Logging 3.0.1.0 for
I'm using Ninject 2.2.1.4 and Ninject.Extensions.Wcf 2.2.0.4. My service is decorated with the following
Using Ninject and MVVMLight. Using a TransientScope binding to viewmodel. When the view is
I'm using Ninject for my DI and Ninject.Extensions.Logging (with NLog) for Logger injection. I
I am using Ninject to load several modules. When two modules try to bind
from what dll can i get the extension of Intercept ? I've added Ninject.Extensions.Interception

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.