我在下面的代码行中出现内存泄漏。
var fixedSequence = xpsDoc.GetFixedDocumentSequence();
if (fixedSequence == null) return;
我在下面尝试了解决方案。添加UpdateLayout无法解决问题。
https://stackoverflow.com/a/7102886
https://stackoverflow.com/a/2410588
由于Windows服务崩溃,我面临两个例外:
- 内存超出异常(在XpsDocument.GetFixedDocumentSequence())
- 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()