title: Umbraco 8 and IoC
body: <p>I installed Umbraco 8.1.3 and i'm trying to configure dependecy injection following this <a href="https://our.umbraco.com/forum/umbraco-8/95955-umbraco-8-and-ioc" rel="nofollow noreferrer">post</a>, but not work. 
  My code is:</p>
  
  <p>CONTROLLER:</p>
  
  <pre><code>public class ContactController : UmbracoApiController
  {
      private readonly IContactService contactService;
  
      public ContactController(IContactService contactService)
      {
          this.contactService = contactService;
      }
  
      [HttpPost]
      public void Post([FromBody]ContactDto request)
      {
          this.contactService.Register(request);
      }
  }
  </code></pre>
  
  <p>SERVICES:</p>
  
  <pre><code>public interface IContactService
  {
      void Register(ContactDto contact);
  }
  
  
  
  public class ContactService : IContactService
  {
      public ContactService()
      {
      }
  
      public void Register(ContactDto contact)
      {
        //Implement
      }
  }
  </code></pre>
  
  <p>DI Config:</p>
  
  <pre><code>public class ApplicationComposer : IUserComposer
  {
      public void Compose(Composition composition)
      {
          composition.RegisterFor&lt;IContactService, ContactService&gt;();
      }
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>"Message": "An error has occurred.",
    "ExceptionMessage": "An error occurred when trying to create a controller of type 'ContactController'. Make sure that the controller has a parameterless public constructor.",
    "ExceptionType": "System.InvalidOperationException",
    "StackTrace": "   at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__15.MoveNext()",
    "InnerException": {
        "Message": "An error has occurred.",
        "ExceptionMessage": "Unable to resolve type: MySite.Controllers.ContactController, service name: ",
        "ExceptionType": "System.InvalidOperationException",
        "StackTrace": "   at LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 4748\r\n   at LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 4705\r\n   at LightInject.ServiceContainer.TryGetInstance(Type serviceType) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 3493\r\n   at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func<code>1&amp; activator)\r\n   at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)",
        "InnerException": {
            "Message": "An error has occurred.",
            "ExceptionMessage": "Unresolved dependency [Target Type: MySite.Controllers.ContactController], [Parameter: contactService(IServices.Contacts.IContactService)], [Requested dependency: ServiceType:IServices.Contacts.IContactService, ServiceName:]",
            "ExceptionType": "System.InvalidOperationException",
            "StackTrace": "   at LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency) in C:\\projects\\lightinject\\src\\LightInject\\LightInject.cs:line 4163\r\n   at LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action</code>1 decoratorTargetEmitter) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 4120\r\n   at LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action<code>1 decoratorTargetEmitMethod) in C:\\projects\\lightinject\\src\\LightInject\\LightInject.cs:line 4081\r\n   at LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter) in C:\\projects\\lightinject\\src\\LightInject\\LightInject.cs:line 4038\r\n   at LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action</code>1 serviceEmitter) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 3777\r\n   at LightInject.ServiceContainer.CreateInstanceDelegateIndex(Action<code>1 emitMethod) in C:\\projects\\lightinject\\src\\LightInject\\LightInject.cs:line 4693\r\n   at System.Collections.Concurrent.ConcurrentDictionary</code>2.GetOrAdd(TKey key, Func<code>2 valueFactory)\r\n   at LightInject.ServiceContainer.EmitLifetime(ServiceRegistration serviceRegistration, Action</code>1 emitMethod, IEmitter emitter) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 4664\r\n   at LightInject.ServiceContainer.&lt;>c__DisplayClass153_0.b__0(IEmitter ms) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 3856\r\n   at LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action<code>1 serviceEmitter) in C:\\projects\\lightinject\\src\\LightInject\\LightInject.cs:line 3777\r\n   at LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError) in C:\\projects\\lightinject\\src\\LightInject\\LightInject.cs:line 4743",
            "InnerException": {
                "Message": "An error has occurred.",
                "ExceptionMessage": "Missing public constructor for Type: IServices.Contacts.IContactService",
                "ExceptionType": "System.InvalidOperationException",
                "StackTrace": "   at LightInject.MostResolvableConstructorSelector.Execute(Type implementingType) in C:\\projects\\lightinject\\src\\LightInject\\LightInject.cs:line 5558\r\n   at LightInject.TypeConstructionInfoBuilder.Execute(Registration registration) in C:\\projects\\lightinject\\src\\LightInject\\LightInject.cs:line 5719\r\n   at System.Collections.Concurrent.ConcurrentDictionary</code>2.GetOrAdd(TKey key, Func`2 valueFactory)\r\n   at LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 4028\r\n   at LightInject.ServiceContainer.&lt;>c__DisplayClass153_0.b__0(IEmitter ms) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 3856\r\n   at LightInject.ServiceContainer.&lt;>c__DisplayClass153_0.b__0(IEmitter ms) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 3856\r\n   at LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency) in C:\projects\lightinject\src\LightInject\LightInject.cs:line 4158"
            }
        }</p>
  </blockquote>
  
  <p>Can anybody help me?</p>