How to register types varying parameter constructor [Unity IoC]
<p>I have the interafes and classes above in my project:</p>

<pre><code>public interface IRepositoryBase&lt;T&gt; : IDisposable where T : class { }
public interface IUserRepository : IRepositoryBase&lt;User&gt; { }
public interface IPaymentRepository : IRepositoryBase&lt;Payment&gt; { }
public class SecurityContext : DbContext { }
public class FinanceContext : DbContext { }

public class RepositoryBase&lt;T&gt; : IRepositoryBase&lt;T&gt; where T : class
{
    public RepositoryBase(DbContext context) { }
}
</code></pre>

<p>I'm trying to inject the correct DbContext to the objects created from the IUserRepository e IPaymentRepository interfaces:</p>

<ul>
<li>IUserRepository -> should be resolved as new RepositoryBase(new
SecurityContext()) </li>
<li>IPaymentRepository -> should be resolved as new
RepositoryBase(new FinanceContext())</li>
</ul>

<p>I tried the code below without success:</p>

<pre><code>container.RegisterType&lt;IUserRepository, RepositoryBase&lt;User&gt;&gt;(
    new InjectionConstructor(container.Resolve&lt;SecurityContext&gt;()));
</code></pre>

<p>... and got the following error</p>

<blockquote>
  <p>The type 'RepositoryBase' cannot be used as type parameter 'TTo'
  in the generic type or method
  'Microsoft.Practices.Unity.UnityContainerExtensions.RegisterType(Microsoft.Practices.Unity.IUnityContainer,
  params Microsoft.Practices.Unity.InjectionMember[])'. There is no
  implicit reference conversion from 'RepositoryBase' to
  'IUserRepository'.</p>
</blockquote>

<p><strong>[EDIT]</strong>
I changed the approach as Georg suggested and It's working great.</p>

<p>After eliminate the IUserRepository and IPaymentRepository interfaces I registered the type as following:</p>

<pre><code>    container.RegisterType&lt;IRepositoryBase&lt;User&gt;, RepositoryBase&lt;User&gt;&gt;
        (new InjectionConstructor(typeof(SecurityContext)));
</code></pre>

<p>Finally I just had to change my Service to recieve an IRepositoryBase injected in its constructor.</p>

<pre><code>public class UserService : IUserService
{
    private readonly IRepositoryBase&lt;User&gt; _repository;

    public ColaboradorService(IRepositoryBase&lt;User&gt; repository)
    {
        _repository = repository;
    }
}
</code></pre>