I have an unmanaged application which uses a WPF assembly for some of its user interface.
Initially I was getting exceptions like:
System.IO.FileNotFoundException was unhandled Message: Could not load file or assembly 'PresentationFramework ...
(Not for the same reason as Changed framework version results in: Could not load file or assembly PresentationFramework?).
PresentationFramework
IS a reference of my assembly.
I have worked around this by adding a line of C# code that seems to force or trick the compiler / runtime into loading the DLL:
// Refers to an arbitrary enum in PresentationFramework.Classic.dll
var dummy = Microsoft.Windows.Themes.ClassicBorderStyle.None;
and then I get no exception at runtime.
Otherwise the only reference to anything in that DLL was in XAML. Specifically:
<ResourceDictionary Source="pack://application:,,,/PresentationFramework.Classic;component/themes/Classic.xaml"/>
But apparently this XAML reference is insufficient to get the DLL to be loaded correctly at runtime.
This 'dummy' solution is OK in that it does work, but I don't understand why this is necessary and it makes me think I've missed something more important.
Is this a correct workaround? What is the reason that this is necessary in the first place?