I am attempting to build a Styles and Controls assembly that other engineers at my office can use. For example, I have a type (MSpinner) derived from the WPFToolKit's DoubleUpDown control. I have a set of styles for this MSpinner control as well.
In a test Executable, I am using the technique detailed here for accessing the resources, which I also followed for creating the resource assembly.
I am also using the Costura.Fody Assembly Embedding tools off NuGet on the resource library so that I can embed the WPFToolKit assembly into my resource library assembly.
My resource library assembly builds just fine. I then go ahead and use my resource library assembly as a reference in a new test WPF executable.
My usage is as follows.
<Window x:Class="UIPart.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ignore="http://www.galasoft.ch/ignore"
xmlns:controls="clr-namespace:MyResources.Controls;assembly=MyResources"
mc:Ignorable="d ignore"
Height="300"
Width="300"
Title="MVVM Light Application"
DataContext="{Binding Main, Source={StaticResource Locator}}">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Skins/MainSkin.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid x:Name="LayoutRoot">
<controls:MSpinner/>
</Grid>
</Window>
However, when I compile the executable, i get the following error.
Severity Code Description Project File Line Suppression State Error Unknown build error, 'Cannot resolve dependency to assembly 'Xceed.Wpf.Toolkit, Version=2.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event. Line 24 Position 10.' UIPart C:\Users\heyyouthere\Documents\Visual Studio 2015\Projects\ResourceDictionaryExample\UIPart\MainWindow.xaml 24
My first thought here is that the Costura.Fody isn't doing it's job right and is not embedding the WPF.ToolKit assembly, but it actually is, according to the byte size of the resultant resource library assembly, which is larger indeed when Costura.Fody's embedding is performed.
I then thought to go ahead and also reference the WPFToolKit itself in the executable, which sounds a little redundant, sure, but why not. So I installed it from NuGet, and behold, the error is gone and everything works.
Doing that isn't a solution for me however. All the resources and all depdencies of those resources need to be consolidated into my resource library, WPFToolkit included for me to consider this a success.
My question is why is the assembly resolving not happening? Is there some signature not matching? Is something explicitly looking for the Xceed.Wpf.Toolkit.dll file on disk? Aren't the types defined in the Xceed.Wpf.Toolkit.dll embedded in my resource library thanks to Fody?