title: Can Unity Framework instantiate a class in a different namespace than a given interface?
body: <p>I have an interface:</p>
  
  <pre><code>namespace IF.Model
  {
      public interface IAllocationGroupRepository
      {
      }
  }
  </code></pre>
  
  <p>and a class the implements that interface:</p>
  
  <pre><code>using IF.Model;
  namespace IF.Repository
  {
      public class AllocationGroupRepository : IAllocationGroupRepository
      {
      }
  }
  </code></pre>
  
  <p>In a Unity Framework call, I can .RegisterType() in the code for both of them:</p>
  
  <pre><code> IUnityContainer container = new UnityContainer();
   container.RegisterType&lt;IAllocationItemRepository, AllocationItemRepository&gt;();
   IAllocationItemRepository _allocationItemRepository = container.Resolve&lt;IAllocationItemRepository&gt;();
  </code></pre>
  
  <p>and .Resolve() works and gives me a new AllocationItemRepository object.</p>
  
  <p>BUT, when I try to call Resolve and the mapping lives in the app.config file, I get this error:</p>
  
  <p>"The current type, IF.Model.IAllocationItemRepository, is an interface and cannot be constructed. Are you missing a type mapping?"</p>
  
  <p>Here is what my app.config file looks like:
  
      
          
              
          </p>
  
  <pre><code>    &lt;unity&gt;
          &lt;containers&gt;
              &lt;container&gt;
                  &lt;types&gt;
                      &lt;type
                          type="IF.Model.IAllocationGroupRepository, IF.Model"
                          mapTo="IF.Repository.AllocationGroupRepository, IF.Repository" /&gt;
                  &lt;/types&gt;
              &lt;/container&gt;
          &lt;/containers&gt;
      &lt;/unity&gt;
  </code></pre>
  
  <p></p>
  
  <p>here is what the code looks like trying to call .Resolve() using what's in the App.config file:</p>
  
  <pre><code>IUnityContainer container = new UnityContainer();
  UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
  section.Containers.Default.Configure(container);
  IAllocationItemRepository _allocationItemRepository = container.Resolve&lt;IAllocationItemRepository&gt;();
  </code></pre>
  
  <p>as you can see, this is pretty basic stuff. Given an interface, resolve it to the class. It works when doing it inline, but fails when trying to do it from the app.config file.</p>
  
  <p>What am I missing here?</p>
  
  <p>Thanks,
  Mike</p>