WPF and Windows 10 crash

本文关键字:crash Windows and WPF | 更新日期: 2023-09-27 18:15:50

我们有一个WPF应用程序,需要与登录和注销各自PC的不同用户保持较长时间(过夜)。

[Update] WPF应用程序使用单实例技术从这里:http://blogs.microsoft.co.il/blogs/arik/SingleInstance.cs.txt单实例特性不是导致

错误的原因。

有一个奇怪的崩溃只发生在以下情况:

  1. 操作系统是Windows 10

  2. 以下用户登录/注销顺序必须发生:

帐号A正在启动应用并注销或锁定PC。帐户B在夜间登录,在PC上工作一会儿,然后注销。账户A在早上再次签到。应用程序运行,但UI被冻结/最小化。当单击/尝试调整大小时,发生以下错误:

   System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
   at System.Windows.Media.Composition.DUCE.Channel.SyncFlush()
   at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)
   at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)
   at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

我已经看过这些帖子了

  • WPF中的win32窗口
  • https://social.msdn.microsoft.com/forums/vstudio/en us/a29b9b58 - 376 c - 49 - b7 - a6b7 fba6a510524a/wpf -和- windows - 10 - crash?forum=wpf
  • http://www.actiprosoftware.com/community/thread/3849/minimize-navbar-floating-window-size-out-of-m

我尝试了上面帖子中的建议,但没有运气。

而且,我不能始终如一地重现这个问题。似乎两次登录之间需要一段时间才能出现问题。

谢谢你的建议

WPF and Windows 10 crash

似乎这是已知的WPF错误:https://github.com/dotnet/wpf/issues/4392020年6月3日还没有解决方案

系统。OutOfMemoryException或System.Windows.Media.Composition.DUCE.Channel.SyncFlush()中的System.Runtime.InteropServices.COMException通常是由GDI对象或User对象泄漏引起的。

您可以在任务管理器中监视这些泄漏。为此选择"GDI对象"或"用户对象"列。如果GDI对象数量超过限制(10000是windows的默认值),你会在应用程序中得到OutOfMemory异常。

检查您的应用程序是否有系统泄漏。绘制命名空间对象引用,忘记销毁的图标句柄,等等…

有关更多信息,请参见https://blogs.msdn.microsoft.com/dsui_team/2013/11/18/wpf-render-thread-failures/

如果你在应用程序中使用PNG位图图像,请尝试将其更改为其他格式,如BMP, GIF或JPEG。. net框架将PNG解码传递给视频驱动程序,一些驱动程序有签名/未签名的错误,可能会请求千兆字节的RAM来解码图像,导致内存不足错误。