WPF executable won't run outside of Visual Studio (resource dictionary issue)

孤街浪徒 提交于 2019-12-08 18:41:48

问题


I have a WPF app that works beautifully if I "debug" (F5) in Visual Studio (Debug and Release mode both work), but if I try to double-click the .exe in the bin\Release folder, Windows kills the application immediately.

The problem appears to be that the executable can't find "PresentationFramework.Aero", which I added to my App's resource dictionaries as follows:

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary
        Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml" />
    <ResourceDictionary
        Source="pack://application:,,,/WPFToolkit;component/Themes/Aero.NormalColor.xaml" />
</ResourceDictionary.MergedDictionaries>

What is the proper way to include the Aero theme (or point to it) so I can release my app?


Here's the exact error I'm getting:

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


回答1:


Turned out I just needed to add some detail to my first ResourceDictionary declaration:

<ResourceDictionary
    Source="/PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml" />


来源:https://stackoverflow.com/questions/3249860/wpf-executable-wont-run-outside-of-visual-studio-resource-dictionary-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!