title: Resolve may fail depending on order of RegisterInstance and RegisterType
body: <p>When using this object model:</p>
  
  <pre><code>interface IInterface {}
  
  class Impl : IInterface
  {
      public Impl(int blah) {}
  }
  </code></pre>
  
  <p>And this test:</p>
  
  <pre><code>void Test1()
  {
      IUnityContainer container = new UnityContainer();
      container.RegisterInstance(new Impl(3), new ContainerControlledLifetimeManager());
      container.RegisterType&lt;IInterface, Impl&gt;(new ContainerControlledLifetimeManager());
  
      Impl impl = container.Resolve&lt;Impl&gt;();
  }
  </code></pre>
  
  <p>I get an exception:</p>
  
  <p><code>Resolution of the dependency failed, type = "BlahMain.Program+Impl", name = "(none)".</code><br>
  <code>Exception occurred while: while resolving.</code><br>
  <code>Exception is: InvalidOperationException - The type Int32 cannot be constructed. You must configure the container to supply this value.</code><br>
  <code>-----------------------------------------------</code><br>
  <code>At the time of the exception, the container was:</code><br>
  <code>Resolving BlahMain.Program+Impl,(none)</code><br>
  <code>Resolving parameter "blah" of constructor BlahMain.Program+Impl(System.Int32 blah)</code><br>
  <code>Resolving System.Int32,(none)</code>  </p>
  
  <p>It looks like Unity is trying to construct its own Impl instance, even though I have already registered one.</p>
  
  <p>Changing the registration order as follows:</p>
  
  <pre><code>void Test2()
  {
      IUnityContainer container = new UnityContainer();
      // Note: RegisterInstance is now called after RegisterType.
      container.RegisterType&lt;IInterface, Impl&gt;(new ContainerControlledLifetimeManager());
      container.RegisterInstance(new Impl(3), new ContainerControlledLifetimeManager());
  
      Impl impl = container.Resolve&lt;Impl&gt;();
  }
  </code></pre>
  
  <p>solves the issue.</p>
  
  <p>Now, changing the order of registrations is an acceptable workaround, but it forces me to think when setting up the container. I was hoping that when using Unity I wouldn't have to worry about registration order.</p>
  
  <p>Can anyone explain this behavior? Is this such a delicate use-case that I have to be aware of registration order?</p>
  
  <hr>
  
  <p>Damian,</p>
  
  <p>This is what I'm trying to do and I'm getting the same error. Is this not what you meant?</p>
  
  <pre><code>void Test3()
  {
      IUnityContainer container = new UnityContainer();
      var impl = new Impl(3);
      container.RegisterInstance(impl, new ContainerControlledLifetimeManager());
      container.RegisterInstance&lt;IInterface&gt;(impl, new ContainerControlledLifetimeManager());
      container.RegisterType&lt;IInterface, Impl&gt;(new ContainerControlledLifetimeManager());
  
      var resolvedImpl = container.Resolve&lt;Impl&gt;();
  }
  </code></pre>