title: Object reference not set to an instance of an object, Unity Dependency Resolver
body: <p>My <code>IUserService</code> is null, not sure what's going on.
  This is my <code>AccountController</code>:</p>
  
  <pre><code>private readonly ICustomMembershipProvider _membershipProvider;
  
  public AccountController(ICustomMembershipProvider provider)
  {
       _membershipProvider = provider;
  }
  //other code omitted
  </code></pre>
  
  <p>My <code>CustomMembershipProvider</code>:</p>
  
  <pre><code>public class CustomMembershipProvider : MembershipProvider, ICustomMembershipProvider
  {
  private IUserService _userService;
  
      public CustomMembershipProvider()
          : this(DependencyResolver.Current.GetService&lt;IUserService&gt;())
      {
      }
  
      public CustomMembershipProvider(IUserService userService)
      {
          _userService = userService;
      }
  //other code omitted
  </code></pre>
  
  <p>When I try to register a user, and the following method is called, my <code>_userService</code> is null, and that's what is causing the error but not sure why it's happening.</p>
  
  <pre><code>public override MembershipUser GetUser(string username, bool userIsOnline)
  {
      var tempUser = _userService.GetByName(username);
  //other code omitted
  </code></pre>
  
  <p>All other dependencies get resolved successfully</p>