title: Dependency injection :-An error occurred when trying to create a controller of type 'controller'
body: <p>The controller :</p>
  
  <pre><code>private readonly IService _service;
  
  public DisplayController(IService service)
  {
      _service = service;
  }
  
  public ActionResult Index(int resultid)
  {
  
      var response = _service.GetQuizResults(resultid);
  
      var alltheresults = Mapper.Map&lt;Services.Contracts.Model.Quiz, Quiz&gt;(response);
  
      return View(alltheresults);
  }
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>InvalidOperationException: An error occurred when trying to create a
    controller of type
    'Travelers.eBusiness.RiskQuiz.Web.Controllers.DisplayController'. Make
    sure that the controller has a parameterless public constructor</p>
  </blockquote>
  
  <p>After a lot of googling I did add another constructor :</p>
  
  <pre><code>public DisplayController()
  {
  
  }
  </code></pre>
  
  <p>It did resolve the error, but <code>_service</code> becomes null.</p>