5

I want to add the PresentationFramework.Aero theme to my ResourceDictionary. The ResourceDictionary itself is in one assembly called ProjectResources. Within this assembly I define all my styles for my project. So this ResourceDictionary is used by several different assemblies in my project. So far it worked fine for all my Dictionaries defined.

Now i want to add the Aero theme. But I always get the exception:

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Inner Exception:

{"Could not load file or assembly 'PresentationFramework.Aero, Culture=neutral' or one of its dependencies. The system cannot find the file specified.":"PresentationFramework.Aero, Culture=neutral"}

The ResourceDictionary is defined like that:

<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/ImageDefinition.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/Brushes.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesLabel.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesTextBox.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesButton.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesTabControl.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesTextBox.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesBorder.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesListView.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesWindow.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesIndicator.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesSearchBox.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ProjectResources;component/ProjectResources/Dictionaries/StylesTreeView.xaml"/>
                <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

I have also added the reference to PresentationFramework.Aero.dll.

So I don't understand why it cant find the defined theme. What is the problem with this definition? Did I miss anything else beside this definition to be able to use the theme?

SOLVED: As toumir said in his comment. You need to set the parameter

Copy Local = true

of the PresentationFramework.Aero DLL. By doing that the dll will be copied to the root directory of your program and it will the dll.

ck84vi
  • 1,556
  • 7
  • 27
  • 49
  • are you copied the PresentationFramework.Aero.dll into your current execution directory? or set to true to CopyLocal to the dll when you reference it – toumir Oct 28 '15 at 12:33
  • @toumir: Thx a lot. What a stupid mistake. I tried a lot of things. But i really forgot to set "Copy Local" to true. – ck84vi Oct 29 '15 at 05:34

1 Answers1

1

I think you need to add the full assembly info to the ResourceDictionary Source:

<ResourceDictionary Source="/PresentationFramework.Aero,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml" />
Glen Thomas
  • 10,190
  • 5
  • 33
  • 65