Showing all posts tagged: 'Dependency Injection'

A 3-post collection

.NET Core Dependency Injection with constructor parameters

This post will be short and sweet, albeit one that caused me a bit of a headache. I recently worked on an ASP.NET Core project and I wanted to take advantage of the built-in Dependency Injection service to inject various services to the controllers. However, one of the services required a parameter in the constructor. This is not highly unusual so I was expecting to quickly find an example in the official docs, explaining how to do this. My search, however, returned no results. I then turned to Google/Bing but guess what? Nothing. Every example I found re-iterated …[read more]


Dependency Injection in ASP.NET WebForms with StructureMap

Ahhh, the beautiful world of Dependency Injection (DI) trying to find it's way back in ASP.NET WebForms. What is it with me and ASP.NET WebForms lately? Just when I think I left all this behind, more and more work is thrown my way using this technology. ASP.NET forms has been around for a while and will also be an integral part of "One ASP.NET", so it is not a lost skill after all. I'm currently working on a major migration project bringin a 1.1 ASP.NET website to the 21st century-ish. All the …[read more]


Mutliple object definition files with Spring.Net

Spring.Net is a great IoC (Inversion of Control) framework that allows developers to implement Dependency Injection using an xml configuration. In most cases, the Spring config will end up in either your app/ web.config files. However, in some cases, it may be desirable or necessary to keep the Spring object definitions outside your app/web.config files in order to be able to share them across multiple projects, eg your website and your unit tests. The Spring.Net framework has a feature to allows us to do this easily, but there are a few caveats that I will …[read more]