/ ASP.NET

Fixing "resolve service" in MVC 6

I have started to expriement with ASP.NET 5 MVC 6. I was trying to get a simple web component to work, when I kept receiving an InvalidOperationException.

An unhandled exception occurred while processing the request. InvalidOperationException: Unable to resolve service for type 'custom.Interface' while attempting to activate 'ViewComponents.customViewComponent'.

I finally realized I needed to add

services.AddTransient<CustomInterface, ConcreteImplementation>();

to my startup.cs. This code is used by ASP.NET Dependency Injection framework to resolve the service / interface with the correct type.