I recently upgraded from Windows 7 to Windows 10. Among the myriad problems I've run into, was the inability to run my Progression toolkit from within Visual Studio. Progression uses AvalonDock 1.3, which doesn't seem to get along with Windows 10 (or Windows 8, based on my research). Curiously, the program builds and can run outside of Visual Studio, but when run with the debugger, this exception is thrown:
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Additional information: Could not load file or assembly 'AvalonDock.Aero2, Version=1.3.3600.0, Culture=neutral, PublicKeyToken=85a1e0ada7ec13e4' or one of its dependencies. The system cannot find the file specified.
This appears to be the result of Windows 10 loading a new Aero2 theme that AvalonDock was unprepared for. After spending a few minutes trying to cheat by copying the existing DLL to match the new name, I decided to take the approach of forcing my application to use the old Windows 7 Aero theme. The top results on StackOverflow, which involved adding a reference to the PresentationFramework.Aero dll and editing the resource XAML, did not solve my problem. Then I found an article appropriately named How to Actually Change the System Theme in WPF. The article is worth a read, but here's the solution, shamelessly copied:
public partial class App : Application
/// Sets the WPF system theme.
/// The name of the theme. (ie "aero")
/// The name of the color. (ie "normalcolor")
public static void SetTheme(string themeName, string themeColor)
const BindingFlags staticNonPublic = BindingFlags.Static | BindingFlags.NonPublic;
var presentationFrameworkAsm = Assembly.GetAssembly(typeof(Window));
var themeWrapper = presentationFrameworkAsm.GetType("MS.Win32.UxThemeWrapper");
var isActiveField = themeWrapper.GetField("_isActive", staticNonPublic);
var themeColorField = themeWrapper.GetField("_themeColor", staticNonPublic);
var themeNameField = themeWrapper.GetField("_themeName", staticNonPublic);
// Set this to true so WPF doesn't default to classic.
With that in place, the application no longer crashes when Visual Studio starts it.