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.
Everything compiles correctly, but when I try to access any of the Autofac-registered types:
public static ILogger Logger => ServiceLocator.Current.GetInstance<ILogger>();
public static IWixViewModel WixViewModel => ServiceLocator.Current.GetInstance<IWixViewModel>();
I get the following exception:
System.IO.FileLoadException occurred HResult=0x80131040
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)
Source=Olbert.Wix.MinimalUI StackTrace: at Olbert.Wix.ViewModels.WixLocator.<>c__DisplayClass0_0.<.cctor>b__5() in C:\Programming\LanHistory\WixUI\viewmodels\WixLocator.cs:line 99
at Microsoft.Practices.ServiceLocation.ServiceLocator.get_Current()
at Olbert.Wix.ViewModels.WixLocator.get_WixViewModel() in C:\Programming\LanHistory\WixUI\viewmodels\WixLocator.cs:line 103
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()
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.
Here's my bundle.wxs file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle Name="LanHistoryBootstrapper"
Version="0.5.0.0"
Manufacturer="Jump for Joy Software"
UpgradeCode="1db721ec-d675-4e60-a55b-d134497a5a35">
<BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)Olbert.LanHistorySetupUI.dll"/>
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Autofac.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Autofac.Extras.CommonServiceLocator.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\BootstrapperCore.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.Extras.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.Extras.pdb" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.pdb" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.Platform.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\GalaSoft.MvvmLight.Platform.pdb" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Microsoft.Practices.ServiceLocation.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Microsoft.Practices.ServiceLocation.pdb" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.j4j.UI.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.j4j.UI.pdb" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.Wix.MinimalUI.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.Wix.MinimalUI.dll.config" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Olbert.Wix.MinimalUI.pdb" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Serilog.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Serilog.Sinks.File.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\Serilog.Sinks.RollingFile.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)\System.Windows.Interactivity.dll" />
<Payload SourceFile="$(var.LanHistorySetupUI.TargetDir)BootstrapperCore.config"/>
</BootstrapperApplicationRef>
<Chain>
<!-- TODO: Define the list of chained packages. -->
<!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
<PackageGroupRef Id="NetFx462Web"/>
<MsiPackage SourceFile="$(var.LanHistorySetup.TargetDir)LanHistorySetup.msi" />
</Chain>
</Bundle>
</Wix>
And here's the BootstrapperCore.config file:
<?xml version="1.0" encoding="utf-8" ?>
<!-- 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. -->
<configuration>
<configSections>
<sectionGroup name="wix.bootstrapper" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore">
<section name="host" type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore" />
</sectionGroup>
</configSections>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
<wix.bootstrapper>
<!-- Example only. Use only if the startup/supportedRuntime above cannot discern supported frameworks. -->
<!--
<supportedFramework version="v4\Client" />
<supportedFramework version="v3.5" />
<supportedFramework version="v3.0" />
-->
<!-- Example only. Replace the host/@assemblyName attribute with assembly that implements BootstrapperApplication. -->
<host assemblyName="Olbert.LanHistorySetupUI" />
</wix.bootstrapper>
</configuration>
The app.config file for the WPF UI component is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /></startup></configuration>