0

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

Background

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...

Example:

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)

asked Nov 26, 2014 at 20:53
3
  • What are you looking for? Batch-Registration? simpleinjector.readthedocs.org/en/latest/… Commented Dec 27, 2014 at 9:49
  • Thank you Thomas, I actually figured this all out already. I didn't find a good one stop shop resource, rather I was able to use a few sources and trial and error to figure it out. Commented Dec 29, 2014 at 18:19
  • Related: stackoverflow.com/questions/9501604/… Commented Apr 18, 2015 at 22:55

1 Answer 1

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.

answered Nov 27, 2014 at 7:27
3
  • 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. Commented 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. Commented 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... Commented Nov 29, 2014 at 4:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.