异常:System.Resources.MissingManifestResourceException 在寻找 themes\generic.baml 时

Exception: System.Resources.MissingManifestResourceException while looking for themes\generic.baml

我收到异常:

Exception thrown: 'System.Resources.MissingManifestResourceException' in mscorlib.dll Additional information: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Arction.WPF.LightningChartUltimate.g.resources" was correctly embedded or linked into assembly "Arction.WPF.LightningChartUltimate" at compile time, or that all the satellite assemblies required are loadable and fully signed.

当我尝试使用选定对象从 WpfToolkit-PropertyGrid 展开节点时发生异常:LightningChartUltimate。问题来自两个 "enum" 的属性。如果我阻止将两个枚举作为 propertyGrid 的属性进行处理,一切都很好,不再有异常。

当我查看堆栈时,我可以发现 WPF 正在寻找文件:"themes\generic.baml"。

有人知道问题的根源吗?

As additional informations (2015-11-17): I've tested with another app which gave me a different behavior, it does not searches for the themes/generic.baml. But both applications gave me same results for theses:

My main app:

  • Debug.Print(Thread.CurrentThread.CurrentCulture.ToString()); = fr-CA
  • Debug.Print(Thread.CurrentThread.CurrentUICulture.ToString()); = en-US

My little test app:

  • Debug.Print(Thread.CurrentThread.CurrentCulture.ToString()); = fr-CA
  • Debug.Print(Thread.CurrentThread.CurrentUICulture.ToString()); = en-US

堆栈仅由 Microsoft 代码组成:

mscorlib.dll!System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(string fileName)    Unknown
    mscorlib.dll!System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary<string, System.Resources.ResourceSet> localResourceSets, bool tryParents, bool createIfNotExists, ref System.Threading.StackCrawlMark stackMark)   Unknown
    mscorlib.dll!System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo requestedCulture, bool createIfNotExists, bool tryParents, ref System.Threading.StackCrawlMark stackMark) Unknown
    mscorlib.dll!System.Resources.ResourceManager.InternalGetResourceSet(System.Globalization.CultureInfo culture, bool createIfNotExists, bool tryParents) Unknown
    mscorlib.dll!System.Resources.ResourceManager.GetObject(string name, System.Globalization.CultureInfo culture, bool wrapUnmanagedMemStream) Unknown
    mscorlib.dll!System.Resources.ResourceManager.GetStream(string name, System.Globalization.CultureInfo culture)  Unknown
>   PresentationFramework.dll!System.Windows.SystemResources.ResourceDictionaries.LoadDictionary(System.Reflection.Assembly assembly, string assemblyName, string resourceName, bool isTraceEnabled) Line 775   C#
    PresentationFramework.dll!System.Windows.SystemResources.ResourceDictionaries.LoadGenericDictionary(bool isTraceEnabled) Line 637   C#
    PresentationFramework.dll!System.Windows.SystemResources.FindDictionaryResource(object key, System.Type typeKey, System.Windows.ResourceKey resourceKey, bool isTraceEnabled, bool allowDeferredResourceReference, bool mustReturnDeferredResourceReference, out bool canCache) Line 316    C#
    PresentationFramework.dll!System.Windows.SystemResources.FindResourceInternal(object key, bool allowDeferredResourceReference, bool mustReturnDeferredResourceReference) Line 176   C#
    PresentationFramework.dll!MS.Internal.Helper.FindTemplateResourceFromAppOrSystem(System.Windows.DependencyObject target, System.Collections.ArrayList keys, int exactMatch, ref int bestMatch) Line 130 C#
    PresentationFramework.dll!System.Windows.FrameworkElement.FindTemplateResourceInternal(System.Windows.DependencyObject target, object item, System.Type templateType) Line 1476 C#
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.DefaultSelector.SelectTemplate(object item, System.Windows.DependencyObject container) Line 1156 C#
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.ChooseTemplate() Line 547    C#
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.EnsureTemplate() Line 836    C#
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.OnPreApplyTemplate() Line 480    C#
    PresentationFramework.dll!System.Windows.FrameworkElement.ApplyTemplate() Line 356  C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4280  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCell(int cell, bool forceInfinityV) Line 1430 C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCellsGroup(int cellsHead, System.Windows.Size referenceSize, bool ignoreDesiredSizeU, bool forceInfinityV, out bool hasDesiredSizeUChanged) Line 1282 C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCellsGroup(int cellsHead, System.Windows.Size referenceSize, bool ignoreDesiredSizeU, bool forceInfinityV) Line 1245  C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureOverride(System.Windows.Size constraint) Line 653 C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Control.MeasureOverride(System.Windows.Size constraint) Line 712  C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!MS.Internal.Helper.MeasureElementWithSingleChild(System.Windows.UIElement element, System.Windows.Size constraint) Line 548   C#
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.MeasureOverride(System.Windows.Size constraint) Line 495 C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Control.MeasureOverride(System.Windows.Size constraint) Line 712  C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Border.MeasureOverride(System.Windows.Size constraint) Line 241   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCell(int cell, bool forceInfinityV) Line 1430 C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCellsGroup(int cellsHead, System.Windows.Size referenceSize, bool ignoreDesiredSizeU, bool forceInfinityV, out bool hasDesiredSizeUChanged) Line 1282 C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCellsGroup(int cellsHead, System.Windows.Size referenceSize, bool ignoreDesiredSizeU, bool forceInfinityV) Line 1245  C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureOverride(System.Windows.Size constraint) Line 653 C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Border.MeasureOverride(System.Windows.Size constraint) Line 241   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Control.MeasureOverride(System.Windows.Size constraint) Line 712  C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.VirtualizingStackPanel.MeasureChild(ref System.Windows.Controls.Primitives.IItemContainerGenerator generator, ref System.Windows.Controls.Primitives.IContainItemStorage itemStorageProvider, ref System.Windows.Controls.Primitives.IContainItemStorage parentItemStorageProvider, ref object parentItem, ref bool hasUniformOrAverageContainerSizeBeenSet, ref double computedUniformOrAverageContainerSize, ref bool computedAreContainersUniformlySized, ref System.Collections.IList items, ref object item, ref System.Collections.IList children, ref int childIndex, ref bool visualOrderChanged, ref bool isHorizontal, ref System.Windows.Size childConstraint, ref System.Windows.Rect viewport, ref System.Windows.Controls.VirtualizationCacheLength cacheSize, ref System.Windows.Controls.VirtualizationCacheLengthUnit cacheUnit, ref bool foundFirstItemInViewport, ref double firstItemInViewportOffset, ref System.Windows.Size stackPixelSize, ref System.Windows.Size stackPixelSizeInViewport, ref System.Windows.Size stackPixelSizeInCacheBeforeViewport, ref System.Windows.Size stackPixelSizeInCacheAfterViewport, ref System.Windows.Size stackLogicalSize, ref System.Windows.Size stackLogicalSizeInViewport, ref System.Windows.Size stackLogicalSizeInCacheBeforeViewport, ref System.Windows.Size stackLogicalSizeInCacheAfterViewport, ref bool mustDisableVirtualization, bool isBeforeFirstItem, bool isAfterFirstItem, bool isAfterLastItem, bool skipActualMeasure, bool skipGeneration, ref bool hasBringIntoViewContainerBeenMeasured, ref bool hasVirtualizingChildren) Line 6830    C#
    PresentationFramework.dll!System.Windows.Controls.VirtualizingStackPanel.MeasureOverrideImpl(System.Windows.Size constraint, ref double? lastPageSafeOffset, ref System.Collections.Generic.List<double> previouslyMeasuredOffsets, ref double? lastPagePixelSize, bool remeasure) Line 2251    C#
    PresentationFramework.dll!System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(System.Windows.Size constraint) Line 1708  C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!MS.Internal.Helper.MeasureElementWithSingleChild(System.Windows.UIElement element, System.Windows.Size constraint) Line 548   C#
    PresentationFramework.dll!System.Windows.Controls.ItemsPresenter.MeasureOverride(System.Windows.Size constraint) Line 73    C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!MS.Internal.Helper.MeasureElementWithSingleChild(System.Windows.UIElement element, System.Windows.Size constraint) Line 548   C#
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.MeasureOverride(System.Windows.Size constraint) Line 495 C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Border.MeasureOverride(System.Windows.Size constraint) Line 241   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Border.MeasureOverride(System.Windows.Size constraint) Line 241   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCell(int cell, bool forceInfinityV) Line 1430 C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCellsGroup(int cellsHead, System.Windows.Size referenceSize, bool ignoreDesiredSizeU, bool forceInfinityV, out bool hasDesiredSizeUChanged) Line 1282 C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureCellsGroup(int cellsHead, System.Windows.Size referenceSize, bool ignoreDesiredSizeU, bool forceInfinityV) Line 1245  C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureOverride(System.Windows.Size constraint) Line 653 C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Control.MeasureOverride(System.Windows.Size constraint) Line 712  C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Border.MeasureOverride(System.Windows.Size constraint) Line 241   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Control.MeasureOverride(System.Windows.Size constraint) Line 712  C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.StackPanel.StackMeasureHelper(System.Windows.Controls.IStackMeasure measureElement, System.Windows.Controls.IStackMeasureScrollData scrollData, System.Windows.Size constraint) Line 584  C#
    PresentationFramework.dll!System.Windows.Controls.StackPanel.MeasureOverride(System.Windows.Size constraint) Line 524   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!MS.Internal.Helper.MeasureElementWithSingleChild(System.Windows.UIElement element, System.Windows.Size constraint) Line 548   C#
    PresentationFramework.dll!System.Windows.Controls.ItemsPresenter.MeasureOverride(System.Windows.Size constraint) Line 73    C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Border.MeasureOverride(System.Windows.Size constraint) Line 241   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Control.MeasureOverride(System.Windows.Size constraint) Line 712  C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!MS.Internal.Helper.MeasureElementWithSingleChild(System.Windows.UIElement element, System.Windows.Size constraint) Line 548   C#
    PresentationFramework.dll!System.Windows.Controls.ContentPresenter.MeasureOverride(System.Windows.Size constraint) Line 495 C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Border.MeasureOverride(System.Windows.Size constraint) Line 241   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Border.MeasureOverride(System.Windows.Size constraint) Line 241   C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationFramework.dll!System.Windows.Controls.Grid.MeasureOverride(System.Windows.Size constraint) Line 435 C#
    PresentationFramework.dll!System.Windows.FrameworkElement.MeasureCore(System.Windows.Size availableSize) Line 4363  C#
    PresentationCore.dll!System.Windows.UIElement.Measure(System.Windows.Size availableSize) Line 664   C#
    PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayout() Line 317    C#
    PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayoutCallback(object arg) Line 589  C#
    PresentationCore.dll!System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork() Line 1562    C#
    PresentationCore.dll!System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() Line 1949  C#
    PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandlerCore(object resizedCompositionTarget) Line 1826  C#
    PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandler(object resizedCompositionTarget) Line 1721  C#
    WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 104 C#
    WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 37 C#
    WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() Line 583  C#
    WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state) Line 528 C#
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
    WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() Line 441  C#
    WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() Line 2232    C#
    WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 2485    C#
    WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 341    C#
    WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Line 494    C#
    WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 104 C#
    WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 37 C#
    WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Line 1445 C#
    WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 392 C#
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Line 2281 C#
    WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) Line 369  C#
    PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) Line 2756 C#
    PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) Line 1845    C#
    PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window window) Line 261 C#
    PresentationFramework.dll!System.Windows.Application.Run() Line 222 C#
    ParametricStudyAnalysis.exe!ParametricStudyAnalysis.App.Main()  C#

Arction.WPF.LightningChartUltimate 在其程序集中不使用任何模板、样式或基于主题的资源。因此,如果程序集正在寻找 themes\generic.bamlgeneric.xaml 的编译版本),那是因为他们的代码必须在他们的 AssemblyInfo.cs 代码文件中包含错误的 ThemeInfoAttribute 定义。

在他们的 AssemblyInfo.cs 文件中验证以下代码:

[assembly: ThemeInfo(
    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
    //(used if a resource is not found in the page, 
    // or application resource dictionaries)
    ResourceDictionaryLocation.None //where the generic resource dictionary is located
    //(used if a resource is not found in the page, 
    // app, or any theme specific resource dictionaries)
)]

确保第二个参数是 ResourceDictionaryLocation.None 默认值是 ResourceDictionaryLocation.SourceAssembly 他们很容易忘记调整它的值。