title: Attempt to load wrong Autofac assembly in Wix bootstrapper project
body: <p>I’m building a WPF UI to use with bootstrapper on an install. The WPF UI uses Autofac for DI, and the common service locator.</p>
  
  <p>Everything compiles correctly, but when I try to access any of the Autofac-registered types:</p>
  
  <pre><code>public static ILogger Logger =&gt; ServiceLocator.Current.GetInstance&lt;ILogger&gt;();
  public static IWixViewModel WixViewModel =&gt; ServiceLocator.Current.GetInstance&lt;IWixViewModel&gt;();
  </code></pre>
  
  <p>I get the following exception:</p>
  
  <blockquote>
    <p>System.IO.FileLoadException occurred   HResult=0x80131040<br>
    Message=Could not load file or assembly 'Autofac, Version=3.5.0.0,
    Culture=neutral, PublicKeyToken=17863af14b0044da' or one of its
    dependencies. The located assembly's manifest definition does not
    match the assembly reference. (Exception from HRESULT: 0x80131040)<br>
    Source=Olbert.Wix.MinimalUI   StackTrace:    at
    Olbert.Wix.ViewModels.WixLocator.&lt;>c__DisplayClass0_0.&lt;.cctor>b__5()
    in C:\Programming\LanHistory\WixUI\viewmodels\WixLocator.cs:line 99<br>
    at Microsoft.Practices.ServiceLocation.ServiceLocator.get_Current()<br>
    at Olbert.Wix.ViewModels.WixLocator.get_WixViewModel() in
    C:\Programming\LanHistory\WixUI\viewmodels\WixLocator.cs:line 103<br>
    at Olbert.Wix.WixApp.Run() in
    C:\Programming\LanHistory\WixUI\WixApp.cs:line 28    at
    System.Threading.ThreadHelper.ThreadStart_Context(Object state)    at
    System.Threading.ExecutionContext.RunInternal(ExecutionContext
    executionContext, ContextCallback callback, Object state, Boolean
    preserveSyncCtx)    at
    System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state, Boolean
    preserveSyncCtx)    at
    System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state)    at
    System.Threading.ThreadHelper.ThreadStart()</p>
  </blockquote>
  
  <p>What's confusing me is that nowhere in any of the projects in this solution do I reference anything other than Autofac 4.5. So why is something trying to load v3.5? AFAIK, the WIX toolset doesn't use Autofac, so I don't think that's the source of the problem.</p>
  
  <p>Here's my bundle.wxs file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
      &lt;Bundle Name="LanHistoryBootstrapper" 
            Version="0.5.0.0" 
            Manufacturer="Jump for Joy Software" 
            UpgradeCode="1db721ec-d675-4e60-a55b-d134497a5a35"&gt;
      &lt;BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost"&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)Olbert.LanHistorySetupUI.dll"/&gt;
  
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Autofac.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Autofac.Extras.CommonServiceLocator.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\BootstrapperCore.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.Extras.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.Extras.pdb" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.pdb" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.Platform.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.Platform.pdb" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Microsoft.Practices.ServiceLocation.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Microsoft.Practices.ServiceLocation.pdb" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.j4j.UI.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.j4j.UI.pdb" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.Wix.MinimalUI.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.Wix.MinimalUI.dll.config" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.Wix.MinimalUI.pdb" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Serilog.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Serilog.Sinks.File.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Serilog.Sinks.RollingFile.dll" /&gt;
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\System.Windows.Interactivity.dll" /&gt;
  
        &lt;Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)BootstrapperCore.config"/&gt;
      &lt;/BootstrapperApplicationRef&gt;
  
          &lt;Chain&gt;
              &lt;!-- TODO: Define the list of chained packages. --&gt;
              &lt;!-- &lt;MsiPackage SourceFile="path\to\your.msi" /&gt; --&gt;
  
        &lt;PackageGroupRef Id="NetFx462Web"/&gt;
        &lt;MsiPackage SourceFile="$(var.LanHistorySetup.TargetDir)LanHistorySetup.msi" /&gt;
          &lt;/Chain&gt;
      &lt;/Bundle&gt;
  &lt;/Wix&gt;
  </code></pre>
  
  <p>And here's the BootstrapperCore.config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --&gt;
  
  
  &lt;configuration&gt;
      &lt;configSections&gt;
          &lt;sectionGroup name="wix.bootstrapper" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore"&gt;
              &lt;section name="host" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore" /&gt;
          &lt;/sectionGroup&gt;
      &lt;/configSections&gt;
      &lt;startup useLegacyV2RuntimeActivationPolicy="true"&gt;
          &lt;supportedRuntime version="v4.0" /&gt;
          &lt;supportedRuntime version="v2.0.50727" /&gt;
      &lt;/startup&gt;
      &lt;wix.bootstrapper&gt;
          &lt;!-- Example only. Use only if the startup/supportedRuntime above cannot discern supported frameworks. --&gt;
          &lt;!--
          &lt;supportedFramework version="v4\Client" /&gt;
          &lt;supportedFramework version="v3.5" /&gt;
          &lt;supportedFramework version="v3.0" /&gt;
          --&gt;
  
          &lt;!-- Example only. Replace the host/@assemblyName attribute with assembly that implements BootstrapperApplication. --&gt;
          &lt;host assemblyName="Olbert.LanHistorySetupUI" /&gt;
      &lt;/wix.bootstrapper&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The app.config file for the WPF UI component is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
  &lt;startup&gt;&lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /&gt;&lt;/startup&gt;&lt;/configuration&gt;
  </code></pre>