C# – MVVM application architecture, where to put dependency injection configuration class, BusinessLayer and Common interfaces

Architecturecdependency-injectiondomain-driven-designmvvm

Planning my architecture for an MVVM application I come to this:

  • MyApp.UI
    • View
  • MyApp.BusinessLayer
    • ViewModel
  • MyApp.DataAccessLayer
    • RepositoryImplEF
  • MyApp.DomainLayer
    • DomainObject
    • RepositoryInterface
  • MyApp.Common
    • Logging
    • Security
    • Utility (contains some reflection method used by many levels)
    • CustomException
  • MyApp.UnitTest

I was inspired by Domain-driven-desing, test-driven-development and onion architecture but not sure to have done all well.

I am not sure of a couple of things:

  1. where to put dependency injection configuration class? In the common project?
  2. where to put BusinessLayer interfaces? in Domain layer?
  3. where to put Common interfaces? in Domain layer? But Common in referenced from domain (for some reflection utilities and for DI if the response to 1. is yes) and circular reference isn't good

Best Answer

We have a fairly large MVVM application that I helped design. We have a single project known as the Host. this will be the main executable for the entire applicaton and contains the Bootstrapper for the Dependency Injection.

  • MyApp.Host
    • Bootstrapping
    • Configure container for all dependencies
    • Runs the main application

Also we had separate class libraries for all our interfaces so we would have:

  • MyApp.ViewModels.Interfaces

This will allow your application to have no circular references as it will only be the Host app that needs to know about the relationship between your viewmodels and the interfaces.

Related Topic