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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:45:30+00:00 2026-06-10T12:45:30+00:00

I have a solution which has the following projects: Core (contains classes for processing,

  • 0

I have a solution which has the following projects:

  • Core (contains classes for processing, not related to business objects / domain)
  • Domain (contains business objects)
  • Harness (console app)
  • MVC4 app
  • Persistence (contains implementations of repository interfaces, EF mappings, etc)
  • Repositories (contains repository interface)
  • Tests (contains unit tests)

I would like to use NInject as my IoC container as I have experience with it however I am open to suggestions for something that would better suit my needs.

The domain objects need to know about the repository so they can do data access (i.e. the Person class might want to retrieve all AddressDetails). Everything is coded to interfaces to help with mocks in unit testing.

I don’t want the domain project taking on a dependence on an IoC container but I need some way of having all instances created in the domain project getting the right repositories injected. How can I do this? I also want to be able to do injections from the harness and test project where necessary. The only way I can think of doing this is by having a static object in the Domain class which wraps the StandardKernel from NInject and call that to populate the dependencies. It would be nice also if i can have constructor injection working which I don’t think it would using that method. The other alternative I can think of is have a factory which builds the domain objects with the correct dependencies, but I’d rather be able to have IPerson person = new Person() rather than have to call a factory each time.

Thanks in advance.

  • 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-10T12:45:32+00:00Added an answer on June 10, 2026 at 12:45 pm

    Sounds like you should introduce Composition Root into MVC4 project and console application. Thus all dependencies will be coupled only there for whole production code. Also you may define your own implementation of StandardKernel, or use autodiscovery to find all implementations.

    There is two examples how to implement composition root with overload of StandartKernel and autodiscovery at ninject.web.mvc that could be useful as starting point. Composition root for console application usually has trivial implementation.

    For test project you could use ninject.mockingkernel with appopriate mocking library, or build all dependencies yourself. Second option should be obvious for pure unittesting, but for integration tests first one is more appopriate.

    Injection of domain objects

    • First there are several well know injection method:

      • via constructor,
      • property,
      • method
      • context.

      For example, implement only one not default constructor for domain object, that defines all required dependencies for that object. If it depends on repository, specify this in constuctor of domain object, and there is no other way to create this particular domain object without specifing it.

    • Second, by doing so you could avoid dependency on any dependency injection library
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ntier solution which has a Domain project for my POCO classes.
I have a solution which has multiple output projects (a website, and admin tool,
I have a solution which has many projects inside it. I build the solution
I have a solution which contains six projects. Four of the projects are class
I have a VS2005 solution which contains a variety of projects (C++ DLLs, C++
I have a solution with following projects GUI (contains views) ViewModels (contains all view
I have a Solution called Framework which is a C# assembly for my business
I'm doing a solution which has a 3 projects(c#). Main executable project Dll Dll
Within my main VS solution I have the following 3 projects: The host hosts
I have three projects in my solution: Domain layer GUI MVC application Now my

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.