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 6810577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:13:20+00:00 2026-05-26T20:13:20+00:00

I am using Ninject for DI. I have Ninject Modules that bind some services

  • 0

I am using Ninject for DI. I have Ninject Modules that bind some services to the Kernel and use binded object in other modules as a service.
To clear the situation let’s see some lines of code:
This is my security module. It provides a service named PermissionManagerContainer.

public class SecurityModule : NinjectModule
{
    public override void Load()
    {
        Bind<IPermissionManagerContainer>().To<PermissionManagerContainer>().InSingletonScope();
    }
}

At the other hand I have a FormServices module that should add an item to the injected PermissionManagerContainer. I think the code must be something like this:

public class FormServicesModule : NinjectModule
{
    [Ninject.Inject]
    private IPermissionManagerContainer permissionManagerContainer { get; set; }

    public override void Load()
    {
        permissionManagerContainer.RegisterManager(formServicesPermissionManager);
    }
}

So in a page named ManagePermissions.aspx again I inject the PermissionManagerContainer and create user interface for Permission Managers of all modules. For example, I need to secure Forms in my FormServices module and define permissions for every form in that service.

But I think there are no guarantee for binding PermissionManagerContainer before injecting it in another module!

Actually, I have my own solution for this problem. I can write an abstract class named MyModule which is sub classed from NinjectModule and write an abstract method called InitializeModule. and call RegisterManager in that method. Then call the InitializeModule for every module loaded, after loading all modules in kernel.

But my questions are:

  1. Does Ninject has this feature internally or not?
  2. It is probable to Ninject manage this case internally and I could call the RegisterManager in the load method. Is it true?
  • 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-26T20:13:21+00:00Added an answer on May 26, 2026 at 8:13 pm

    You are misunderstanding the purpose of modules. They are there to configure Ninject. They themselves shouldn’t have any dependencies at all. The RegisterManager belongs somewhere in a service or startup action of your application. Or probably you have to change the way the permission manager works so that it takes an enumerable of all configured managers instead of registering them. But it’s nearly impossible to tell what is best from the question — just that you are abusing modules for something they are not intended for.

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

Sidebar

Related Questions

I have set up a NInject (using version 1.5) binding like this: Bind<ISessionFactory>().ToMethod<ISessionFactory>(ctx =>
I am using Ninject to load several modules. When two modules try to bind
We have a concrete singleton service which implements Ninject.IInitializable and 2 interfaces. Problem is
I have been using Ninject as the IOC for an XNA project, and was
I have a WCF web service in which I want to use my Repositories
Using Ninject 2.2, I have the following failing test (simplified): public interface IGenericView<T> {
Hi I'm using ninject with an MVC app. I'm sure I have it setup
Does anybody out there know how to use Ninject with a WCF webHttp Service
I'm using Ninject 2.2.1.4 and Ninject.Extensions.Wcf 2.2.0.4. My service is decorated with the following
I'm currently using Ninject to create instances of interfaces in a WCF Services application.

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.