title: .NET Core Identity and Simple Injector. Crosswire not working
body: <p>I am using simple injector (4.8.1) on a project that uses asp.net core identity. I tried to crosswise UserManager but I got an error saying
  <code> No service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Tenancy.Core.Domain.AppUser]' has been registered.&quot;</code>
  the SimpleInjectorConfig class is:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public static class SimpleInjectorConfig
  {
      private static Container _container;
  
      public static void ConfigureServices(IServiceCollection services, IConfiguration config,
          IWebHostEnvironment env)
      {
          _container = new Container();
  
          _container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
  
          _container.ConfigureCore(config, env);
  
          _container.RegisterInitializer&lt;BaseApiController&gt;(controller =&gt;
          {
              controller.Mediator = _container.GetInstance&lt;IMediator&gt;();
          });
  
          services.AddSingleton(_container);
          services.AddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt;();
  
          services.AddControllers();
  
          services.AddLogging();
          // Sets up the basic configuration that for integrating Simple Injector with
          // ASP.NET Core by setting the DefaultScopedLifestyle, and setting up auto
          // cross wiring.
          services.AddSimpleInjector(_container, options =&gt;
          {
              // AddAspNetCore() wraps web requests in a Simple Injector scope and
              // allows request-scoped framework services to be resolved.
              options
                  .AddAspNetCore()
                  .AddControllerActivation();
              options.AddLogging();
              options.CrossWire&lt;UserManager&lt;AppUser&gt;&gt;();
          });
      }
  
      public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          app.UseSimpleInjector(_container);
          app.UseRouting();
          app.UseAuthorization();
          app.UseEndpoints(endpoints =&gt; { endpoints.MapControllers(); });
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
              IdentityModelEventSource.ShowPII = true;
          }
          //app.UseHttpsRedirection();
  
          _container.Verify();
      }
  }
  </code></pre>
  <p>and I called it in my Startup.cs file</p>
  <pre class="lang-cs prettyprint-override"><code> public class Startup
  {
      public IConfiguration _configuration { get; }
      public IWebHostEnvironment _env { get; }
  
      public Startup(IConfiguration configuration, IWebHostEnvironment env)
      {
          _configuration = configuration;
          _env = env;
      }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          SimpleInjectorConfig.ConfigureServices(services, _configuration, _env);
          CorsConfig.ConfigureServices(services);
          DatabaseConfig.ConfigureServices(services, _configuration);
          MvcConfig.ConfigureServices(services);
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          SimpleInjectorConfig.Configure(app, env);
          CorsConfig.Configure(app, _configuration);
          MvcConfig.Configure(app);
      }
  }
  </code></pre>
  <p>The configurations have their own class and called in the Startup called in the Startup class just to keep it clean, SimpleInjectorConfig is the config class for simple injector.</p>