I'm trying to find a good resource, advice, etc in a project I've taken on for myself at work.


When I started here we had a application that was part MVC part Webform (separate projects on solution) that was tightly coupled to it's DAL with business code all over the place.

I refactored the entire solution into the onion layer architecture almost two years ago using ninject. killed of it's SOAP services in favor of WebAPI and moved the vast majority of the webforms into MVC overtime. (still some left in webforms, but their days are numbered)

Overall this has been a major success in regards to maintainability, stability, and getting our business logic where it belongs. Lately though performance has been a growing issue. We've establish multiple causes, but we were surprised at how badly ninject was impacting our performance, after some research we found ninject was infact one of the worst DI frameworks from a performance stand point. With this in mind we're moving to simple injector as it impressed us.

The problem

We don't just rewrite our work, we gradually move it where able. We all know we can't realistic blend ninject with simple and not expect utter chaos. With that in mind we cleaned up our code to make sure it all would work with both ninject and simple and we're to that final step of actually wiring the whole thing up...

Except every guide, tutorial, and example I've found has the actual UI project (MVC) reference both the interface and the project I'll inject my classes from...


container.Register<ILoggingService, LoggingService>();

With Onion Architecture we strived to make sure our front end had no direct references to the supporting code. This was handled by having a project separate from my MVC project to handle injection thereby allowing me to never have a reference between my UI and my backend code. (Thus preventing you from accidentally bypassing your interface and DI)

The above would require me to directly reference the backend code and in my opinion fundamentally defeat what we've strived to do. Perhaps my heads not all together from being tired + mentally on holiday already, but I'm having a heck of a time trying to figure out how to accomplish what we had under ninject in simple injector (I'm sure it's stupid easy, but I've been beating my head on this for hours so any help would go a long way)


1 Answer 1


Usually, there is some kind of "Application" or "Launcher" project, which references every assembly the application needs to run. Only responsibility of this project is to wire up the dependencies and start up the application. It has no UI and no behavior. But I'm not sure how this would handle in MVC application.

  • I know this can be done with MVC, what you describe is more or less how we had it implemented with ninject. We would register all the dependencies in a "dependency resolution" project that contained "ninject modules" that would facilitate this, then you'd reference those modules in your app_start of the MVC project accomplishing the injection, but I'm not seeing how to do this with simple injector. Nov 28, 2014 at 4:13
  • @RualStorge Thats completely different than what I describe. The project I talk about should not be referenced by anything else. It is "top" project.
    – Euphoric
    Nov 28, 2014 at 5:25
  • Gotcha, so it'd be the start up application of some nature... I can see where the concern would be in it working with MVC... I suspect that due to the nature of web applications that may not work, but I also would like to be proven wrong just to have a viable solution... Nov 29, 2014 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.