title: .NET Core 1.0, Enumerate All classes that implement base class
body: <p>I am working on migrating an ASP.NET project to RC2. I am using AutoFac to try to enumerate classes that implement AutoMapper Profile base class to set up all my mapping profiles without having to call them explicitly.  Previously in older version of ASP.NET (even in RC1) I was able to use the following code:</p>
  
  <pre><code>public class AutoMapperModule : Module
  {
  
      protected override void Load(ContainerBuilder builder)
      {
  
          builder.RegisterAssemblyTypes().AssignableTo(typeof(Profile)).As&lt;Profile&gt;();
  
          builder.Register(context =&gt;
          {
              var profiles =
                 AppDomain.CurrentDomain.GetAssemblies()
                 .SelectMany(IoC.GetLoadableTypes)
                 .Where(t =&gt; t != typeof(Profile) &amp;&amp; t.Name != "NamedProfile" &amp;&amp; typeof(Profile).IsAssignableFrom(t));
  
              var config = new MapperConfiguration(cfg =&gt;
              {
                  foreach (var profile in profiles)
                  {
                      cfg.AddProfile((Profile)Activator.CreateInstance(profile));
                  }
              });
              return config;
          })
          .AsSelf()
          .As&lt;IConfigurationProvider&gt;()
          .SingleInstance();
  
          builder.Register(c =&gt; c.Resolve&lt;MapperConfiguration&gt;().CreateMapper(c.Resolve)).As&lt;IMapper&gt;().InstancePerLifetimeScope();
          builder.RegisterType&lt;MappingEngine&gt;().As&lt;IMappingEngine&gt;();
  
      }
  }
  </code></pre>
  
  <p>This worked fantastically, until I tried converting my project to RC2 using the new netcoreapp1.0 framework, except now I am getting a design time error on AppDomain stating the "AppDomain does not exist in the current context". I've seen some suggestions about using ILibraryManager or DependencyContext to do this but I can't figure out how to get any of that to work. Any suggestions?</p>