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

  • SEARCH
  • Home
  • 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 7082405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:02:57+00:00 2026-05-28T07:02:57+00:00

What is the NInject equivalent of the following code that uses Autofac: var builder

  • 0

What is the NInject equivalent of the following code that uses Autofac:

var builder = new ContainerBuilder();

System.Reflection.Assembly assembly = ...;
builder.RegisterAssemblyTypes(assembly).AsClosedTypesOf(typeof(OpenGeneric<>))
                                       .As<IAnInterface>();

var resolved = container.Resolve<IEnumerable<IAnInterface>>();
  • 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-05-28T07:02:58+00:00Added an answer on May 28, 2026 at 7:02 am

    Using Ninject 3.0.0-rc3 you can use

    kernel.Bind(
          x => x.FromThisAssembly()
                .SelectAllClasses().InheritedFrom(typeof(BaseService<>)).WhichAreGeneric()
                .BindToAllInterfaces());
    

    Depending on your requirements you can probably remove the WhichAreGeneric statement. .SelectAllClasses().InheritedFrom(typeof(BaseService<>)).WhichAreGeneric() selects the classes to which a binding is created.

    Conventions ensures that the interface and the implementation class must have the same open type arguments. E.g. In case

    interface IBar<T1, T2>
    interface IBaz<T>
    interface IFoo
    class Bar<T1, T2> : IBar<T1, T2>, IBaz<T1>, IFoo
    class Foo : IBar<int, int>, IFoo
    

    IBar<T1, T2> is the only valid interface for Bar<T1, T2>. But for Foo both IBar<int, int>, IFoo are valid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ninject, Sprint.NET, Unity, Autofac, Castle.Windsor are all examples are IoC frameworks that are available.
I'm new to Ninject so I'm sure that it's something I'm doing wrong, I'm
I am new to ninject, I am wondering how I can run custom initizlisation
My case it is Ninject 2. // normal explicit dispose using (var dc =
Using Ninject 2.2, I have the following failing test (simplified): public interface IGenericView<T> {
I'm trying out Ninject and I'm modifying to code I wrote with Structure Map
Does Ninject have and equivalent method for unity's registerinstance. I want to create a
I'm using Ninject 2.2.1.4 and Ninject.Extensions.Wcf 2.2.0.4. My service is decorated with the following
I have ninject make a new session on httpRequest and close it at the
Is it possible to return a component instance by key using Ninject? The equivalent

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.