WPF '设置属性 'System.Windows.ResourceDictionary.DeferrableContent' 引发异常。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30855261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 13:12:28  来源:igfitidea点击:

WPF 'Set property 'System.Windows.ResourceDictionary.DeferrableContent' threw an exception.'

c#wpfnugetmahapps.metro

提问by mikestram

My application runs fine in VS 2010 but when I copy the executable from the bin folder to another location I get this error:

我的应用程序在 VS 2010 中运行良好,但是当我将可执行文件从 bin 文件夹复制到另一个位置时,出现此错误:

'Set property 'System.Windows.ResourceDictionary.DeferrableContent' threw an exception.' Line number '15' and line position '23'.

'设置属性 'System.Windows.ResourceDictionary.DeferrableContent' 引发异常。行号“15”和行位置“23”。

Did a bit of testing and found out that if I include the 'System.Windows.Controls.Input.Toolkit', 'System.Windows.Controls.Layout.Toolkit', and 'WPFToolkit' Dlls in the same location as the executable it works.

做了一些测试,发现如果我在与可执行文件相同的位置包含“System.Windows.Controls.Input.Toolkit”、“System.Windows.Controls.Layout.Toolkit”和“WPFToolkit”Dlls作品。

My application is using the Infragistics Metro Dark theme which I added using NuGet. This is what I added in my App.xaml:

我的应用程序使用的是我使用 NuGet 添加的 Infragistics Metro Dark 主题。这是我在 App.xaml 中添加的内容:

<Application.Resources>
  <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="/XENON;component/Themes/MetroDark/MetroDark.MSControls.Core.Implicit.xaml" />
      <ResourceDictionary Source="/XENON;component/Themes/MetroDark/MetroDark.MSControls.Toolkit.Implicit.xaml" />
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Application.Resources>

Does anyone know why this is occurring? Any help would be appreciated.

有谁知道为什么会这样?任何帮助,将不胜感激。

采纳答案by mikestram

Found the solution.

找到了解决办法。

Removed MetroDark.MSControls.Toolkit.Implicit.xamlwhich was not needed and also deleted the Reference to the WPFToolkit Dll.

删除了MetroDark.MSControls.Toolkit.Implicit.xaml不需要的内容,并删除了对WPFToolkit Dll.