WPF 可执行文件不会在 Visual Studio 之外运行(资源字典问题) [英] WPF executable won't run outside of Visual Studio (resource dictionary issue)

查看:47
本文介绍了WPF 可执行文件不会在 Visual Studio 之外运行(资源字典问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WPF 应用程序,如果我在 Visual Studio 中调试"(F5)(调试和发布模式都可以),它可以很好地工作,但是如果我尝试双击 bin\Release 文件夹中的 .exe,Windows立即终止应用程序.

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.

问题似乎是可执行文件找不到PresentationFramework.Aero",我将其添加到我的应用程序的资源字典中,如下所示:

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>

包含 Aero 主题(或指向它)以便我可以发布我的应用的正确方法是什么?

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:

无法加载文件或程序集PresentationFramework.Aero,Culture=neutral"或其依赖项之一.系统找不到指定的文件.":"PresentationFramework.Aero, Culture=neutral

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

推荐答案

结果我只需要在我的第一个 ResourceDictionary 声明中添加一些细节:

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" />

这篇关于WPF 可执行文件不会在 Visual Studio 之外运行(资源字典问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆