title: Can I control .NET Core assembly redirects programmatically?
body: <p><strong>Question:</strong> Is there any way in .NET Core 2.0 (netstandard 2.0) how I could apply assembly redirections NOT defined in given <code>application.exe.config</code> file when running executable? Maybe some programmatic way? Or even by running executable with some special settings/flags?</p>
  
  <p><strong>Scenario:</strong>
  Here is simplified scenario that I'm trying to solve in .NET Core 2.0.</p>
  
  <ol>
  <li>There is a "service hosting" executable, let's call it <code>ServiceHost.exe</code></li>
  <li>There is a service <code>.dll</code>, let's call it  <code>Service.dll</code>, which implements some entry interface <code>IService</code> with method <code>Start()</code>.</li>
  <li>When I run <code>ServiceHost.exe --service-assembly Service.dll</code> it loads service and calls its <code>IService.Start()</code> implementation.</li>
  <li>Author of the service can be anyone, it's independent on service host.</li>
  </ol>
  
  <p>Let's say that the service needs some assembly redirects. It's quite common in .NET Core world when you reference much more packages than in old .NET Framework and not all of them have exact versions for latest .NET Core. Using assembly redirects works quite well and allows you to use library targeting older version just fine.</p>
  
  <p>And here comes the problem with my setup. Since <code>Service.dll</code> is a library which is loaded by independent executable its <code>app.config</code> file with assembly redirects is not used. Runtime uses <code>ServiceHost.exe.config</code> and not <code>Service.dll.config</code>, which is expected.</p>
  
  <p><strong>Reminder:</strong> I'm using .NET Core so solution with creating new Application Domain and setting it to load different config file is not an option.</p>