C# XpsDocument.GetFixedDocumentSequence()上的内存泄漏

C# XpsDocument.GetFixedDocumentSequence()上的内存泄漏,c#,xpsdocument,C#,Xpsdocument,我在下面的代码行中发现内存泄漏 var fixedSequence = xpsDoc.GetFixedDocumentSequence(); if (fixedSequence == null) return; 我尝试了以下给定的解决方案。添加UpdateLayout无法解决此问题 var fixedSequence = xpsDoc.GetFixedDocumentSequence(); if (fixedSequence == null) return; var f

我在下面的代码行中发现内存泄漏

 var fixedSequence = xpsDoc.GetFixedDocumentSequence();
 if (fixedSequence == null) return;  
我尝试了以下给定的解决方案。添加UpdateLayout无法解决此问题

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

 var fixedSequence = xpsDoc.GetFixedDocumentSequence();
 if (fixedSequence == null) return;  
由于windows服务崩溃,我面临以下两个例外:

 var fixedSequence = xpsDoc.GetFixedDocumentSequence();
 if (fixedSequence == null) return;  
  • 内存超出异常(在XpsDocument.GetFixedDocumentSequence()处)
  • System.Windows.Markup.XamlParseException
  • System.Windows.Markup.XamlParseException的异常详细信息

     var fixedSequence = xpsDoc.GetFixedDocumentSequence();
     if (fixedSequence == null) return;  
    
    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()
    
    异常信息:System.ComponentModel.Win32Exception 在MS.Win32.UnsafentiveMethods.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) 在MS.Win32.HwndWrapper..ctor处(Int32、Int32、Int32、Int32、Int32、Int32、Int32、System.String、IntPtr、MS.Win32.HwndWrapperHook[]) 位于System.Windows.Media.MediaContextNotificationWindow..ctor(System.Windows.Media.MediaContext) 位于System.Windows.Media.MediaContext..ctor(System.Windows.Threading.Dispatcher) 位于System.Windows.Media.MediaContext.From(System.Windows.Threading.Dispatcher) 在System.Windows.Media.Visual.VerifyApiredWrite()上 位于System.Windows.Media.VisualCollection.Add(System.Windows.Media.Visual) 位于System.Windows.Controls.UIElementCollection.AddInternal(System.Windows.UIElement) 在MS.Internal.Xaml.Runtime.ClrObjectRuntime.Add(System.Object、System.Xaml.XamlType、System.Object、System.Xaml.XamlType) 异常信息:System.Windows.Markup.XamlParseException 位于System.Windows.Markup.XamlReader.RewrapException(System.Exception、System.Xaml.ixamlineinfo、System.Uri) 在System.Windows.Markup.wpfxamloader.Load(System.Xaml.XamlReader、System.Xaml.IXamlObjectWriterFactory、Boolean、System.Object、System.Xaml.XamlObjectWriterSettings、System.Uri) 位于System.Windows.Markup.wpfxamloader.Load(System.Xaml.XamlReader,Boolean,System.Uri) 加载(System.Xaml.XamlReader、System.Windows.Markup.ParserContext) 在System.Windows.Markup.XamlReader.Load(System.Xml.XmlReader、System.Windows.Markup.ParserContext、System.Windows.Markup.XamlParserMode)中 加载(System.IO.Stream、System.Windows.Markup.ParserContext) 在System.Windows.Xps.Packaging.XpsDocument.GetFixedDocumentSequence()中 在Softdocs.Imaging.MultiPageStreamSplitter.b_u1()中 位于System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object,布尔值) 在System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object,布尔值) 在System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object)上运行 位于System.Threading.ThreadHelper.ThreadStart()处