EPiServer 7 Preview – On StructureMapDependencyResolver

With the DI support coming in EPiServer 7 SM sooner or later is going to try and resolve a dependency and fail to do so. Most likely this is due to a container configuration issue and this is where the StructureMapDependencyResolver that ships with the MVC template preview falls slightly short. Not that it won’t resolve your dependencies and inject them but rather be somewhat secretive in case of a missing registration. Let’s say we have a controller with a dependency that we’ve missed to configure.

public StartPageController(IMyContentRepository contentRepository)
    _contentRepository = contentRepository;

When we access the start page we are greeted with the following YSOD:

So what dependency is missing?

If we switch to the StructureMapDependencyResolver implementation outlined in this blog post we still get a YSOD, but a more informative one. Never underestimate the power of debugability.