title: References to Separate Projects When Configuring Unity?
body: <p>I read a really cool blog about <a href="http://anderly.com/2010/11/09/asp-net-mvc-dependency-injection-and-the-bliss-of-truly-decoupled-applications/" rel="nofollow">using Autofac to completely decouple an application</a>. But try as I might (and being horribly new to all this), I just couldn't get Autofac to gel.</p>
  
  <p>I turned to Unity from the MS Patterns &amp; Practices Enterprise Library and that went a whole lot better. To make things unnecessarily hard for myself, I separated out all my stuff into projects as:</p>
  
  <ul>
  <li>UnityDi (Console app)</li>
  <li>UnityDi.Contracts (Interfaces)</li>
  <li>UntiyDi.Domain (Classes)</li>
  <li>UnityDi.Repositories (Data Access)</li>
  <li>UnityDi.Services (Access to repository through a service layer)</li>
  </ul>
  
  <p>I used XML configuration to pony up Unity:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;configSections&gt;
          &lt;section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" /&gt;
      &lt;/configSections&gt;
      &lt;unity xmlns="http://schemas.microsoft.com/practices/2010/unity"&gt;
          &lt;assembly name="UnityDi.Contracts" /&gt;
          &lt;assembly name="UnityDi.Domain" /&gt;
          &lt;assembly name="UnityDi.Services" /&gt;
          &lt;assembly name="UnityDi.Repositories" /&gt;
          &lt;namespace name="UnityDi.Contracts" /&gt;
          &lt;namespace name="UnityDi.Domain" /&gt;
          &lt;namespace name="UnityDi.Services" /&gt;
          &lt;namespace name="UnityDi.Repositories" /&gt;
          &lt;container&gt;
              &lt;register type="IUser" mapTo="User"&gt;&lt;/register&gt;
              &lt;register type="IUserService" mapTo="UserService"&gt;&lt;/register&gt;
              &lt;register type="IUserRepository" mapTo="UserRepository"&gt;&lt;/register&gt;
          &lt;/container&gt;
      &lt;/unity&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And got that into a running app, no worries:</p>
  
  <pre><code>private static readonly IUnityContainer Container = new UnityContainer();
  ...
  Container.LoadConfiguration();
  </code></pre>
  
  <p>BUT in order to do so, I need a reference to all the above projects from my console app.</p>
  
  <p>Is there a way to make the app only ever have a reference to UnityDi.<strong>Contracts</strong> (the interfaces)? Then the app is well and truly decoupled (admittedly with a sledgehammer).</p>
  
  <p>I hope that is enough of an explanation, I'm totally new to this and I'm being extreme like this to facilitate better learning.</p>