wpf 桌面组合被禁用错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17202236/
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
Desktop Composition Is Disabled Error
提问by TrialAndError
In my WPF application on .NET 4.0, I am having users report two errors that seem very intermittent and I cannot get a handle on. Below, I am posting the message and the top-most line of the stack trace. I can post the full stack trace if needed.
在我的 .NET 4.0 上的 WPF 应用程序中,我让用户报告了两个似乎非常断断续续的错误,我无法处理。下面,我发布了消息和堆栈跟踪的最顶层。如果需要,我可以发布完整的堆栈跟踪。
Message: {Desktop composition is disabled} The operation could not be completed because desktop composition is disabled. (Exception from HRESULT: 0x80263001)
StackTrace: at Standard.NativeMethods.DwmExtendFrameIntoClientArea(IntPtr hwnd, MARGINS& pMarInset)
Message: Insufficient memory to continue the execution of the program.
StackTrace: at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()
Google is not proving very helpful, so I was hoping maybe you guys have seen them before.
事实证明,谷歌并没有多大帮助,所以我希望你们以前见过它们。
回答by TrialAndError
I finally was able to nail down the issue - graphics adapter driver.
我终于能够确定问题 - 图形适配器驱动程序。
This post, along with this onehelped me figure it out. Basically, what happened is I had 4 users (out of about 600) that were experiencing issues. They also reported that their screens would flicker at random times and some reported 'task bars turning solid'. This would be what caused the DWM composition error, and apparently if they had multiple programs running that were intensively using the graphics card, it would run out of memory.
这后,随着这一个让我看着办吧。基本上,发生的事情是我有 4 个用户(大约 600 个)遇到问题。他们还报告说他们的屏幕会在随机时间闪烁,有些人报告说“任务栏变实”。这将是导致 DWM 组合错误的原因,显然,如果他们有多个程序正在运行并且大量使用显卡,它就会耗尽内存。
I tested using Geeks3d.com FurMark benchmarking program to max out the graphics card then launched my application. It would crash upon opening and throw the outofmemory exception, so I know it wasn't a memory leak.
我使用 Geeks3d.com FurMark 基准测试程序进行了测试以最大化显卡,然后启动我的应用程序。它会在打开时崩溃并抛出内存不足异常,所以我知道这不是内存泄漏。
After updating the driver, I was unable to generate the crash...even with multiple programs AND FurMark running at full blast.
更新驱动程序后,我无法产生崩溃……即使有多个程序和 FurMark 全速运行。
Hopefully this helps someone down the road.
希望这可以帮助某人。
回答by dsfgsho
The first error is related to the Aero Glass style that you are using in your WPF Window. When the user turns the glass theme off (and uses the basic theme) these Glass methods like DwmExtendFrameIntoClientAreafail. You therefore need to check whether Desktop Window Manager (DWM) composition is enabled:
第一个错误与您在 WPF 窗口中使用的 Aero Glass 样式有关。当用户关闭玻璃主题(并使用基本主题)时,这些玻璃方法如DwmExtendFrameIntoClientArea失败。因此,您需要检查是否启用了桌面窗口管理器 (DWM) 组合:
[DllImport("dwmapi.dll", PreserveSig = false)]
public static extern bool DwmIsCompositionEnabled();
The second problem seems to be an unmanaged bug. Check this very elaborate answer on another very similar question: https://stackoverflow.com/a/1965382/1255010
第二个问题似乎是一个不受管理的错误。在另一个非常相似的问题上查看这个非常详细的答案:https: //stackoverflow.com/a/1965382/1255010

