c# - WPF System.OutOfMemoryException 系统.Windows.Automation.Peers.AutomationPeer.UpdateSubtree

标签 c# .net wpf out-of-memory automationpeer

我在 .NET Framework 4.5.1 上构建了一个 WPF 桌面应用程序。它“通常”工作正常,但是,在某些机器上,在运行时,当要显示 WPF 数据网格时,会出现 System.OutOfMemoryException。

堆栈跟踪报告:

An error of type System.OutOfMemoryException occurred.
       in System.Windows.Controls.ItemContainerGenerator.ContainerFromItem(Object item)
       in Microsoft.Windows.Controls.DataGrid.TryFindCell(Object item, DataGridColumn column)
       in Microsoft.Windows.Automation.Peers.DataGridCellItemAutomationPeer.get_OwningCellPeer()
       in Microsoft.Windows.Automation.Peers.DataGridCellItemAutomationPeer.IsEnabledCore()
       in System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
       in System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
       in System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
       in System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
       in System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
       in System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
       in System.Windows.ContextLayoutManager.fireAutomationEvents()
       in System.Windows.ContextLayoutManager.UpdateLayout()
       in System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       in System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       in System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       in System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       in System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       in System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       in MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

非工作机器是 32 位、Windows 7、2 GB 内存、.NET 框架 4.5.1。

我必须说数据网格只显示几行。 我一直在网上寻找类似的错误,但找不到任何合适的解决方案。

有什么建议吗?

谢谢!

最佳答案

问题原来与运行帐户缺少某些权限有关。

一旦用户通过以下方式启动可执行文件

右键单击,以管理员身份运行

问题消失了。

关于c# - WPF System.OutOfMemoryException 系统.Windows.Automation.Peers.AutomationPeer.UpdateSubtree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32483711/

相关文章:

c# - 停止播放音频剪辑

c# - 正则表达式替换大小写不敏感问题

c# - ContentPresenter 的异常行为

c# - 使用 GDI+ 写入多行字符串

c# - 从 HSL 值创建 C# 颜色

c# - 为什么空字符串不是连接的标识?

c# - 如何使用c#检查硬盘是Sata设备还是IDE设备

c# - 如何获取字符串中 '#'的计数?

c# - 如何将击键发送到 WebBrowser?

如果文本框文本已更改,则 WPF MVVM 调用方法