Skip to content
Mike Larah By Mike Larah Software Engineer III
Using the endjin composition framework in an MVC application

As I was setting up the framework for my apprenticeship portal MVC 4 web application, I used part of endjin's core composition framework for the dependency injection, which utilises Castle Windsor.

(Here is a link to some useful videos on dependency injection and Castle Windsor that helped me to understand why they are used).

Part of the framework uses a class called WindsorContainerBootstrapper which calls a GetInstallers method which looks through all referenced assemblies and finds and returns a list of the Windsor Installers that are contained within them.

This was designed for console applications though. To make this work, I made a change so that it uses the HttpRuntime.BinDirectory method to correctly locate the bin folder where the assemblies are stored in a web application.

This extra class could not be added to Endjin.Core.Composition though as HttpRuntime is dependent on System.Web, and Endjin.Core.Composition uses the .NET 4 Client Profile which does not support this.

So I added a new WindsorContainerWebBootstrapper class to the project and called it in the dependency injection configuration to initialise a new Windsor Container.

This means I can now resolve my types dynamically.

(As a side note, we now have a GitHub Gist plugin installed for the blog so all the pasted code looks pretty)

@MikeLarah

Mike Larah

Software Engineer III

Mike Larah

Mike is a Software Engineer at endjin with almost a decade of experience in solving business problems with technology. He has worked on a wide range of projects for clients across industries such as financial services, recruitment, and retail, with a strong focus on Azure technologies.