??
最近遇到一个情况,应用起来就崩溃, 查看dump信息如下:
0:017> !pe
The version of SOS does not match the version of CLR you are debugging. Please
load the matching version of SOS for the version of CLR you are debugging.
CLR Version: 4.0.30319.225
SOS Version: 4.0.30319.18408
Exception object: 0000000003e09428
Exception type: System.NullReferenceException
Message: 未将对象引用设置到对象的实例。
InnerException: <none>
StackTrace (generated):
SP IP Function
00000000266F58F0 000007FF0067A971 XXXXX.XXXXX.System.Windows.Markup.IStyleConnector.Connect(Int32, System.Object)+0x161
00000000266F5940 000007FED4DB56A8 PresentationFramework_ni!System.Windows.FrameworkTemplate.LoadTemplateXaml(System.Xaml.XamlReader, System.Xaml.XamlObjectWriter)+0xf221e8
00000000266F59E0 000007FED3E93448 PresentationFramework_ni!System.Windows.FrameworkTemplate.LoadTemplateXaml(System.Xaml.XamlObjectWriter)+0x68
00000000266F5A40 000007FED3E93304 PresentationFramework_ni!System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(System.Windows.DependencyObject, System.Windows.Markup.IComponentConnector, System.Windows.Markup.IStyleConnector, System.Collections.Generic.List`1<System.Windows.DependencyObject>, System.Windows.UncommonField`1<System.Collections.Hashtable>)+0x364
00000000266F5AD0 000007FED3E92F76 PresentationFramework_ni!System.Windows.FrameworkTemplate.LoadContent(System.Windows.DependencyObject, System.Collections.Generic.List`1<System.Windows.DependencyObject>)+0x96
00000000266F5B50 000007FED3E92CC4 PresentationFramework_ni!System.Windows.StyleHelper.ApplyTemplateContent(System.Windows.UncommonField`1<System.Collections.Specialized.HybridDictionary[]>,
这个问题原因是.net 4.0不支持嵌套模板中加入event和style, 必须打补丁。
下面是x64版本的补丁。
对应的官方说明:
或者安装.Net 4.0.3的集成补丁包或者.Net 4.5.
WPF中抛出NullReferenceException:System.Windows.Markup.IStyleConnector.Connect(Int32, System.Object)
原文:http://blog.csdn.net/muzizongheng/article/details/50775262