最近遇到一个问题,窗体在Loaded同时Resize会出现黑屏或者直接崩溃, 调查发现是WPF后端的Render线程渲染UI到DirectX时崩溃。
硬件环境:WES7 + .Net4.0
[关于WPF有2个线程的解释如下:](https://msdn.microsoft.com/zh-cn/library/ms741870(v=vs.90).aspx)
*WPF 应用程序从两个线程开始:一个用于处理呈现,一个用于管理 UI。呈现线程有效地隐藏在后台运行,而 UI 线程则接收输入、处理事件、绘制屏幕以及运行应用程序代码。*
遇到的这个问题就是用于处理呈现的线程挂了,异常如下:
Exception from HRESULT: 0x88980406
Stack Trace:
0000000021a4d8d8 000007fef7a66869 [HelperMethodFrame: 0000000021a4d8d8]
0000000021a4da20 000007fee485ae0f System.Windows.Media.Composition.DUCE+Channel.SyncFlush()***WARNING: Unable to verify checksum for PresentationCore.ni.dll
0000000021a4dae0 000007fee3e95615 System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean, System.Nullable`1<ChannelSet>)
0000000021a4dd10 000007fee3eabfec System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean)
0000000021a4dd80 000007fee3eabd0e System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr)
0000000021a4dee0 000007fee3e95fd7 System.Windows.Interop.HwndTarget.HandleMessage(MS.Internal.Interop.WindowMessage, IntPtr, IntPtr)
0000000021a4e070 000007fee3e93d14 System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
0000000021a4e0c0 000007fee4b2b450 MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
**[微软分析的原因及建议方案](http://blogs.msdn.com/b/dsui_team/archive/2013/11/18/wpf-render-thread-failures.aspx)**
1. Update your video drivers, and/or try different video hardware in the problem machine(s). 【试过560、660、770、970显卡都不会解决问题, 试过320.18, 320.49, 353.30等驱动也都不会解决问题】
2. Disable Hardware rendering. As a quick test, you can use the DisableHWAcceleration registry value discussed here. You would set the value to 1 in order to disable WPF's hardware rendering pipeline. Note that this affects all WPF applications running in that user's session, so be advised you might be impacting more than one application. There are other options for disabling hardware acceleration at a more granular level. Starting in .Net 3.5, you can disable it programmatically on a per-window basis by using the HwndTarget.RenderMode property. Starting in .Net 4.0, you can disable it programmatically on a per-process basis by using the RenderOptions.ProcessRenderMode property. 【更改注册表不会解决问题】
3. Upgrade to the latest version and service pack level of the .Net Framework available for your target platform. 【升级到Net 4.5后,问题解决。降级到4.0后,又出现】
4. Disable the use of Windows.AllowsTransparency and Popup.AllowsTransparency in your application.【包装的应用窗体的AllowsTransparency为False】
5. If you are on Windows XP or Windows 2003, test on a newer operating system, and upgrade if possible.【没有测试,升级OS不太可能】
6. If System.OutOfMemoryExceptions are being reported, then monitor the process's memory usage in Performance Monitor; particularly the Process\Virtual Bytes, Process\Private Bytes, and .NET CLR Memory\# Bytes in All Heaps counters. Also monitor the User Objects and GDI Objects for the process in Windows Task Manager. If you can determine that a specific resource is being exhausted, then troubleshoot the application to fix whatever is causing that resource consumption. Ultimately that should resolve the System.OutOfMemoryException.【查看内存和句柄等,没有内存泄露】
**[微软说明](https://connect.microsoft.com/VisualStudio/feedback/details/674249/wpf-renderer-thread-exited-with-codes-0x88980406-0x88980403)**[](https://connect.microsoft.com/VisualStudio/feedback/details/674249/wpf-renderer-thread-exited-with-codes-0x88980406-0x88980403)**[Net 4.5](https://connect.microsoft.com/VisualStudio/feedback/details/674249/wpf-renderer-thread-exited-with-codes-0x88980406-0x88980403)[解决此问题:](https://connect.microsoft.com/VisualStudio/feedback/details/674249/wpf-renderer-thread-exited-with-codes-0x88980406-0x88980403)**
![](https://box.kancloud.cn/2016-02-02_56b0015c43a2d.jpg)
![graphic](image/d41d8cd98f00b204e9800998ecf8427e.png)
- 前言
- win32与WPF的混合编程
- WPF: 一个可以用StoryBoard动态改变Grid行宽/列高的类
- MFC中调用WPF教程
- Expression Blend操作: 使用behavior来控制Storyboard
- WPF DatePicker 的textbox的焦点
- WPF 使用MultiBinding ,TwoWay ,ValidationRule ,需要注意的事项
- WPF TreeView 后台C#选中指定的Item, 需要遍历
- WPF GridViewColumn Sort DataTemplate
- DataGridColum的bug
- WPF Get Multibinding Expression, Update Source,
- WPF 后台触发 Validate UI‘s Element
- WPF ValidationRule 触发ErrorTemplate 的注意事项
- WPF DelegateCommand CanExecute
- WPF TextBox PreviewTextInput handle IME (chinese)
- No overload for &#39;OnStartup&#39; matches delegate &#39;System.Windows.StartupEventHandler&#39;
- WPF error: does not contain a static &#39;Main&#39; method suitable for an entry point
- WPF GridView中的CellTemplate失效的原因
- DataGrid 显示选中的item
- 如何得到WPF中控件绑定的EventTrigger
- 选中DataGrid的Cell而不是row
- ContextMenu的自定义
- 输入框只能输入英文
- TextBox的OnTextboxChanged事件里对Text重新赋值带中文, 导致崩溃
- DataGrid当列宽超出当前宽度时,没有数据也恒有滚动条
- wpf如何获取control template里的元素
- Set connectionId threw an exception.
- WPF中Visible设为Collapse时,VisualTreeHelper.GetChildrenCount为0
- XAML 编码规范 (思考)
- 如何为现有控件的DependencyProperty添加Value Changed事件?
- TreeView滚动TreeViewItem
- 为BindingList添加Sort
- WPF Background的设置有坑
- 自定义Panel中添加依赖属性需要注意的问题
- TextBlock截断字符显示为....
- DataGrid 支持字符截断显示
- TreeView控件实践
- WPF如何更改系统控件的默认高亮颜色 (Highlight brush)
- ViewModel中C# Property自动添加OnPropertyChanged处理的小工具, 以及相应Python知识点
- WPF中Xaml编译正常而Designer Time时出错的解决办法
- 关于Snoop的用法
- wpf中为DataGrid添加checkbox支持多选全选
- WPF中DataGrid控件的过滤(Filter)性能分析及优化
- wpf控件提示Value ‘’ can not convert
- DropShadowEffect导致下拉框控件抖动
- 再论WPF中的UseLayoutRounding和SnapsToDevicePixels
- WPF案例:如何设计历史记录查看UI
- WPF案例:如何设计搜索框(自定义控件的原则和方法)
- WPF基本概念入门
- WPF开发中Designer和码农之间的合作
- 聊聊WPF中的Dispatcher
- 聊聊WPF中字体的设置
- Bug:DataGridCell的显示不完整
- WPF中ToolTip的自定义
- WPF中ItemsControl绑定到Google ProtocolBuffer的结构体时的性能问题
- TreeView的性能问题
- Xaml中string(字符串)常量的定义以及空格的处理
- 依赖属性
- WPF中的CheckBox的_ (underscore / 下划线)丢失
- WPF错误:必须使“Property”具有非 null 值。
- WPF中ItemsControl应用虚拟化时找到子元素的方法
- WPF毫秒级桌面时钟的实现-C#中Hook(钩子)的应用
- KB2464222导致IsNonIdempotentProperty方法找不见
- WPF中PreviewMouseDownEvent的系统处理:TabItem的PreviewMouseDown 事件弹框后不切换的问题调查
- WPF文字渲染相关的问题及解决
- wpf中的默认右键菜单中的复制、粘贴、剪贴等没有本地化的解决方案
- WPF内部DeliverEvent读锁和PrivateAddListener写锁导致死锁
- Windbg调试WPF的依赖属性
- WPF 后台Render线程崩溃, Exception from HRESULT: 0x88980406
- WPF中DependencyObject与DependencyProperty的源码简单剖析
- 禁用WPF中DataGrid默认的鼠标左键拖动多选行的效果
- wpf工程中在Xaml文件下添加多个cs文件
- ScrollViewer滚动到底来触发加载数据的Behavior