title: get type from library assembly
body: <p>I want to create a .NET Core REST API with MediatR. My projects are</p>
  
  <ul>
  <li>API project</li>
  <li>Application project containing the commands, queries and pipeline behaviours</li>
  </ul>
  
  <p>To setup the dependency injection I have to call the </p>
  
  <pre><code>services.AddMediatR(typeof(Startup));
  </code></pre>
  
  <p>in the <code>ConfigureServices</code> method of the <strong>Startup.cs</strong> (API project). My commands and queries come from a different assembly (Application) so I have to pass in the library assembly instead of Startup. Please see the answer from this post</p>
  
  <p><a href="https://stackoverflow.com/questions/55337259/why-doesnt-mediatr-resolve-method-when-entites-are-in-different-projects">Why doesn&#39;t Mediatr resolve method when entites are in different projects?</a></p>
  
  <p>My code should look like</p>
  
  <pre><code>services.AddMediatR(typeof(ApplicationAssembly));
  </code></pre>
  
  <p>but I can't just pass in "Application". What needs to get passed in, when commands and queries come from a library project?</p>
  
  <hr>
  
  <p>I solved it by passing in a class from that library</p>
  
  <pre><code>services.AddMediatR(typeof(Application.Queries.GetUsersQuery));
  </code></pre>
  
  <p>I think this is a really bad approach because when this class gets moved or deleted, the API projects needs to get fixed too.</p>
  
  <p>So any better solutions are highly appreciated</p>