title: Xamarin Forms dependency service don't work with generics?
body: <p>I'm trying to get an instance of generic class in Xamarin.Forms. If I use the code below everything works fine:</p>
  
  <blockquote>
    <p><strong>Interface</strong></p>
  
  <pre><code>namespace PrismNinjectApp1.Application.Interfaces
  {
      public interface IUserService { }
  }
  </code></pre>
    
    <p><strong>Concrete class</strong></p>
  
  <pre><code>[assembly: Dependency(typeof(PrismNinjectApp1.Application.DomainServices.UserService))]
  namespace PrismNinjectApp1.Application.DomainServices
  {
      public class UserService : IUserService
      {
          public UserService() { }
      }
  }
  </code></pre>
    
    <p><strong>View Model</strong></p>
  
  <pre><code>namespace PrismNinjectApp1.ViewModels
  {
      public class MainPageViewModel : BindableBase, INavigationAware
      {
          private readonly IUserService _userService;
  
          public MainPageViewModel()
          {
              _userService = DependencyService.Get&lt;IUserService&gt;();
          }
          //Implementation of INavigationAware interface (I'm using Prism)
      }
  }
  </code></pre>
  </blockquote>
  
  <p>But if I try do the same with generics I can't get the object instance:</p>
  
  <blockquote>
    <p><strong>Interface</strong></p>
  
  <pre><code>namespace PrismNinjectApp1.test
  {
      public interface IMyInterface&lt;T&gt; where T : class { }
  }
  </code></pre>
    
    <p><strong>Concrete class</strong></p>
  
  <pre><code>[assembly: Dependency(typeof(PrismNinjectApp1.test.MyInterface&lt;&gt;))]
  namespace PrismNinjectApp1.test
  {
      public class MyInterface&lt;T&gt; : IMyInterface&lt;T&gt; where T : class { }
  }
  </code></pre>
    
    <p><strong>View Model</strong></p>
  
  <pre><code>namespace PrismNinjectApp1.ViewModels
  {
      public class MainPageViewModel : BindableBase, INavigationAware
      {
          private readonly IMyInterface&lt;Users&gt; _myInterface;
  
          public MainPageViewModel()
          {
              _myInterface = DependencyService.Get&lt;IMyInterface&lt;Users&gt;&gt;(); //Gets NULL value
          }
          //Implementation of INavigationAware interface (I'm using Prism)
      }
  }
  </code></pre>
    
    <p><strong>Users</strong> class is a domain entity</p>
  
  <pre><code>public class Users
      {
          [PrimaryKey, AutoIncrement]
          public int Id { get; set; }
          [MaxLength(100)]
          public string Name { get; set; }
      }
  </code></pre>
  </blockquote>
  
  <p>Any idea how I can get this object instance?</p>
  
  <p>I trying to do this because I want to use generics services and repositories with basic CRUD and search methods with this structure</p>
  
  <ol>
  <li>App (project droid and ios)</li>
  <li>Shared (portable project)</li>
  <li>Application (for external services - portable projec)</li>
  <li>Domain - (portable project)</li>
  <li>Data - (portable project)</li>
  </ol>
  
  <p><strong>Xamarin Forms version:</strong> 2.3.4.247</p>