title: Unity: The type LogWriter cannot be constructed
body: <p>For the following "project" I am getting a very annoying and inexplicable error when resolving Unity for DI.</p>
  
  <blockquote>
    <p>InvalidOperationException - The type LogWriter cannot be constructed.
    You must configure the container to supply this value.</p>
    
    <p>?ex.Message; "Resolution of the dependency failed, type =
    \"WindowsFormsApplication1.Performance\", name =
    \"(none)\".\r\nException occurred while: while resolving.\r\nException
    is: InvalidOperationException - The type LogWriter cannot be
    constructed. You must configure the container to supply this
    value.\r\n-----------------------------------------------\r\nAt the
    time of the exception, the container was:\r\n\r\n  Resolving
    WindowsFormsApplication1.Performance,(none)\r\n  Resolving parameter
    \"lw\" of constructor
    WindowsFormsApplication1.Performance(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter
    lw,
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionManager
    em)\r\n    Resolving
    Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter,(none)\r\n"</p>
    
    <p>?ex.StackTrace; "   at
    Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object
    existing, String name, IEnumerable<code>1 resolverOverrides) in
    e:\\Builds\\Unity\\UnityTemp\\Compile\\Unity\\Unity\\Src\\UnityContainer.cs:line
    515\r\n   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type
    t, String name, IEnumerable</code>1 resolverOverrides) in
    e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs:line
    485\r\n   at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t,
    String name, ResolverOverride[] resolverOverrides) in
    e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs:line
    173\r\n   at
    Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer
    container, ResolverOverride[] overrides) in
    e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainerExtensions.cs:line
    504\r\n   at WindowsFormsApplication1.Form1.OnLoad(EventArgs e) in
    D:\Devzone\Tasking\WindowsFormsApplication1\Form1.cs:line 33"</p>
  </blockquote>
  
  <p>In a form:</p>
  
  <pre><code>  protected override void OnLoad(EventArgs e)
          {
              base.OnLoad(e);
  
              try
              {
                  IUnityContainer container = new UnityContainer();
                  Performance p = container.Resolve&lt;Performance&gt;();
              }
              catch (Exception ex)
              {
  
              }
          }
  </code></pre>
  
  <p>Dependency class:</p>
  
  <pre><code> public class Performance
      {
          public Performance(LogWriter lw, ExceptionManager em)
          {
          }
      }
  </code></pre>
  
  <p>Configuration File:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;configSections&gt;
          &lt;section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /&gt;
          &lt;section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /&gt;
      &lt;/configSections&gt;
      &lt;loggingConfiguration name="" tracingEnabled="true" defaultCategory="General"&gt;
          &lt;listeners&gt;
              &lt;add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                  listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                  source="Enterprise Library Logging" formatter="Text Formatter"
                  log="" machineName="." traceOutputOptions="None" /&gt;
          &lt;/listeners&gt;
          &lt;formatters&gt;
              &lt;add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                  template="Timestamp: {timestamp}{newline}&amp;#xA;Message: {message}{newline}&amp;#xA;Category: {category}{newline}&amp;#xA;Priority: {priority}{newline}&amp;#xA;EventId: {eventid}{newline}&amp;#xA;Severity: {severity}{newline}&amp;#xA;Title:{title}{newline}&amp;#xA;Machine: {localMachine}{newline}&amp;#xA;App Domain: {localAppDomain}{newline}&amp;#xA;ProcessId: {localProcessId}{newline}&amp;#xA;Process Name: {localProcessName}{newline}&amp;#xA;Thread Name: {threadName}{newline}&amp;#xA;Win32 ThreadId:{win32ThreadId}{newline}&amp;#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
                  name="Text Formatter" /&gt;
          &lt;/formatters&gt;
          &lt;categorySources&gt;
              &lt;add switchValue="All" name="General"&gt;
                  &lt;listeners&gt;
                      &lt;add name="Event Log Listener" /&gt;
                  &lt;/listeners&gt;
              &lt;/add&gt;
              &lt;add switchValue="All" name="Category2" /&gt;
          &lt;/categorySources&gt;
          &lt;specialSources&gt;
              &lt;allEvents switchValue="All" name="All Events" /&gt;
              &lt;notProcessed switchValue="All" name="Unprocessed Category" /&gt;
              &lt;errors switchValue="All" name="Logging Errors &amp;amp; Warnings"&gt;
                  &lt;listeners&gt;
                      &lt;add name="Event Log Listener" /&gt;
                  &lt;/listeners&gt;
              &lt;/errors&gt;
          &lt;/specialSources&gt;
      &lt;/loggingConfiguration&gt;
      &lt;exceptionHandling&gt;
          &lt;exceptionPolicies&gt;
              &lt;add name="Policy"&gt;
                  &lt;exceptionTypes&gt;
                      &lt;add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                          postHandlingAction="NotifyRethrow" /&gt;
                  &lt;/exceptionTypes&gt;
              &lt;/add&gt;
          &lt;/exceptionPolicies&gt;
      &lt;/exceptionHandling&gt;
  &lt;/configuration&gt;
  </code></pre>