2

我在下面的代码行中遇到内存泄漏。

 var fixedSequence = xpsDoc.GetFixedDocumentSequence();
 if (fixedSequence == null) return;  

我尝试了以下给出的解决方案。添加 UpdateLayout 无法解决问题。

https://stackoverflow.com/a/7102886
https://stackoverflow.com/a/2410588

由于 Windows 服务崩溃,我面临以下两个异常:

  1. 内存不足异常(在 XpsDocument.GetFixedDocumentSequence())
  2. System.Windows.Markup.XamlParseException

System.Windows.Markup.XamlParseException 的异常详细信息

Exception Info: System.ComponentModel.Win32Exception
   at MS.Win32.UnsafeNativeMethods.CreateWindowEx(Int32, System.String, System.String, Int32, Int32, Int32, Int32, Int32, System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef, System.Object)
   at MS.Win32.HwndWrapper..ctor(Int32, Int32, Int32, Int32, Int32, Int32, Int32, System.String, IntPtr, MS.Win32.HwndWrapperHook[])
   at System.Windows.Media.MediaContextNotificationWindow..ctor(System.Windows.Media.MediaContext)
   at System.Windows.Media.MediaContext..ctor(System.Windows.Threading.Dispatcher)
   at System.Windows.Media.MediaContext.From(System.Windows.Threading.Dispatcher)
   at System.Windows.Media.Visual.VerifyAPIReadWrite()
   at System.Windows.Media.VisualCollection.Add(System.Windows.Media.Visual)
   at System.Windows.Controls.UIElementCollection.AddInternal(System.Windows.UIElement)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.Add(System.Object, System.Xaml.XamlType, System.Object, System.Xaml.XamlType)

Exception Info: System.Windows.Markup.XamlParseException
   at System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
   at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
   at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, Boolean, System.Uri)
   at System.Windows.Markup.XamlReader.Load(System.Xaml.XamlReader, System.Windows.Markup.ParserContext)
   at System.Windows.Markup.XamlReader.Load(System.Xml.XmlReader, System.Windows.Markup.ParserContext, System.Windows.Markup.XamlParseMode)
   at System.Windows.Markup.XamlReader.Load(System.IO.Stream, System.Windows.Markup.ParserContext)
   at System.Windows.Xps.Packaging.XpsDocument.GetFixedDocumentSequence()
   at Softdocs.Imaging.MultiPageStreamSplitter.<OpenXpsDocument>b__1()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()
4

0 回答 0