Strange resource dictionary warnings appear in out

2019-01-25 04:45发布

问题:

I am using Visual studio 2011 beta with the april 2012 update installed .I have my Debugging options -> Output window > WPF trace settings all the values including Resource Dictionaries turned off.But I still continue to see warning messages like

System.Windows.ResourceDictionary Warning: 9 : Resource not found; 
     ResourceKey='CheckBoxCooperStyle1'

How to debug this type of warnings provided they are not false positives ?

回答1:

Reply from Microsoft support team "Thanks for the update. I was afraid of that, since my testing found similar results. It seems there is some internal WPF tracing code which does not adhere to the specified settings. In the meantime, We don’t have any suggestions other than finding the Resource Dictionary (or the relevant type) and correcting the issues that the trace output is warning about.

if a debugger was attached, there will always be some WPF tracing emitted regardless of the settings specified in the IDE (or in the app.config). Unfortunately, the output you are receiving appears to fall into this category. Regrettably, there is no way to turn off all the WPF trace output from being emitted

We could certainly file a feature request for the product for this to be considered in a future release, but otherwise I don’t see a way for you to avoid the issue in the current release.



回答2:

I got these Messages when mixing static resources and dynamic resources. Setting all the Problematic Resource settings to StaticResource solved the problem. Instead of:

Style="{DynamicResource CheckBoxCooperStyle1}"

Use:

Style="{StaticResource CheckBoxCooperStyle1}"