title: DI Unity Container resolution error
body: <p>I am trying to fake Enterprise Library <code>LogWriter</code> so it doesn't perform any logging when I run unit tests, so it looks like this in simplified version:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class MockLogger : ILogger
  {
        public MockLogger()
        {
        }
  
        public void Write(object message)
        {        
        }
  
        public void Write(object message, string category)
        {     
        }
  
        public void Write(object message, string category, int eventId)
        { 
        }
  
        public void Write(object message, string category, int eventId, int priority)
        {
        }
  
        public void Write(object message, string category, int eventId, int priority,   TraceEventType severity)
        {
        }
  }
  
  public class Logger : ILogger
  {
        LogWriter writer;
        public Logger()
        {
            writer = (new LogWriterFactory()).Create();
  
        }
  
        public Logger(LogWriter logWriter)
        {
            writer = logWriter;
        }
  
        public void Write(LogEntry logEntry)
        {
            writer.Write(logEntry);
        }
  
        public void Write(object message)
        {
            writer.Write(message);
        }
  
        public void Write(object message, string category)
        {
            writer.Write(message, category);
        }
  
        public void Write(object message, string category, int eventId)
        {
            writer.Write(message, category, eventId);
        }
  
        public void Write(object message, string category, int eventId, int priority)
        {
            writer.Write(message, category, eventId, priority);
        }
  
        public void Write(object message, string category, int eventId, int priority,   TraceEventType severity)
        {
            writer.Write(message, category, priority, eventId, severity);
        }
  
        public bool ShouldLog(LogEntry logEntry)
        {
            return writer.ShouldLog(logEntry);
        }
  }
  </code></pre>
  
  <p>Then i am trying to resolve it thru configuration:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;unity xmlns="http://schemas.microsoft.com/practices/2012/unity"&gt;
  &lt;alias alias="ILogger" type="ConsoleApplicationTest.ILogger, ConsoleApplicationTest" /&gt;
  &lt;namespace name="ConsoleApplicationTest" /&gt;
  &lt;assembly name="ConsoleApplicationTest" /&gt;
  &lt;container&gt;
    &lt;register type="ConsoleApplicationTest.ILogger, ConsoleApplicationTest" name="logger" mapTo="ConsoleApplicationTest.Logger, ConsoleApplicationTest"&gt;
    &lt;/register&gt;
  &lt;/container&gt;
  &lt;container name="Mock"&gt;
    &lt;register type="ConsoleApplicationTest.ILogger, ConsoleApplicationTest" name="mockLogger" mapTo="ConsoleApplicationTest.MockLogger, ConsoleApplicationTest"&gt;
    &lt;/register&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p></p>
  
  <pre class="lang-cs prettyprint-override"><code>var container = new UnityContainer();
  container.LoadConfiguration();
  var logger = container.Resolve&lt;ILogger&gt;();
  </code></pre>
  
  <p>The error I am getting is the following:</p>
  
  <blockquote>
    <p>Resolution of the dependency failed, type =
    "ConsoleApplicationTest.ILogger", name = "(none)". Exception occurred
    while: while resolving. Exception is: InvalidOperationException - The
    type ILogger does not have an accessible constructor.</p>
  </blockquote>
  
  <p>Both classes have a parameterless constructor. What should I do to resolve this error? Using .NET 4.5</p>