Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XpsDocument.GetFixedDocumentSequence throws an exception #575

Closed
jbe2277 opened this issue Apr 12, 2019 · 6 comments
Closed

XpsDocument.GetFixedDocumentSequence throws an exception #575

jbe2277 opened this issue Apr 12, 2019 · 6 comments
Assignees
Labels
Bug Product bug (most likely) needs-updated-estimate This issue needs an updated estimate regression status: This issue is a regression from a previous build or release
Milestone

Comments

@jbe2277
Copy link

jbe2277 commented Apr 12, 2019

  • .NET Core SDK: 3.0.100-preview5-011256 [e6f157e5a4]
  • Microsoft.WindowsDesktop.App 3.0.0-preview5-27610-56
  • VS 2019: 16.1.0 Preview 1.0
  • Windows version: Win10 1809 (Azure VM, connected via Remote Desktop)
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Reproduce:

Expected: The Print preview should be shown. You could compare this with the master branch (targets .NET 4.6.1)

Actual: The exception System.Windows.Markup.XamlParseException: 'Add value to collection of type 'System.Windows.Documents.DocumentReferenceCollection' threw an exception.' Line number '1' and line position '136'. ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined. is thrown.

Details:
The line FixedDocumentSequence documentSequence = xpsDocument.GetFixedDocumentSequence(); results in the following exception:

System.UriFormatException
  HResult=0x80131537
  Message=Invalid URI: The format of the URI could not be determined.
  Source=System.Private.Uri
  StackTrace:
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)

------ Call stack:
System.Private.Uri.dll!System.Uri.CreateThis(string uri, bool dontEscape, System.UriKind uriKind)
System.Private.Uri.dll!System.Uri.Uri(string uriString)
WindowsBase.dll!MS.Internal.IO.Packaging.PackUriHelper.GetPackageUriComponent(System.Uri packUri)
WindowsBase.dll!MS.Internal.IO.Packaging.PackUriHelper.ValidateAndGetPackUriComponents(System.Uri packUri, out System.Uri packageUri, out System.Uri partUri)
PresentationCore.dll!System.IO.Packaging.PackWebRequestFactory.System.Net.IWebRequestCreate.Create(System.Uri uri)
PresentationCore.dll!System.IO.Packaging.PackWebRequest.GetRequest(bool allowPseudoRequest)
PresentationCore.dll!System.IO.Packaging.PackWebRequest.GetResponse()
PresentationCore.dll!MS.Internal.WpfWebRequestHelper.GetResponse(System.Net.WebRequest request)
PresentationCore.dll!MS.Internal.WpfWebRequestHelper.GetResponseStream(System.Net.WebRequest request, out MS.Internal.ContentType contentType)
PresentationFramework.dll!System.Windows.Documents.DocumentReference._LoadDocument()
PresentationFramework.dll!System.Windows.Documents.DocumentReference.GetDocument(bool forceReload)
PresentationFramework.dll!System.Windows.Documents.FixedDocumentSequence.GetPaginator(System.Windows.Documents.DocumentReference docRef)
PresentationFramework.dll!System.Windows.Documents.FixedDocumentSequence.PageCount.get()
PresentationFramework.dll!System.Windows.Documents.FixedDocumentSequence._OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args)
[Native to Managed Transition]
[Managed to Native Transition]
System.Xaml.dll!System.Xaml.Schema.SafeReflectionInvoker.InvokeMethodCritical(System.Reflection.MethodInfo method, object instance, object[] args)
System.Xaml.dll!System.Xaml.Schema.XamlTypeInvoker.AddToCollection(object instance, object item)
System.Xaml.dll!MS.Internal.Xaml.Runtime.ClrObjectRuntime.Add(object collection, System.Xaml.XamlType collectionType, object value, System.Xaml.XamlType valueXamlType)
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_DoAssignmentToParentCollection(MS.Internal.Xaml.Context.ObjectWriterContext ctx)
System.Xaml.dll!System.Xaml.XamlObjectWriter.WriteEndObject()
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader xamlReader, System.Xaml.XamlObjectWriter xamlWriter, bool onlyLoadOneNode, bool skipJournaledProperties, bool shouldPassLineNumberInfo, System.Xaml.IXamlLineInfo xamlLineInfo, System.Xaml.IXamlLineInfoConsumer xamlLineInfoConsumer, MS.Internal.Xaml.Context.XamlContextStack<System.Windows.Markup.WpfXamlFrame> stack, System.Windows.Markup.IStyleConnector styleConnector)
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader, System.Xaml.IXamlObjectWriterFactory writerFactory, bool skipJournaledProperties, object rootObject, System.Xaml.XamlObjectWriterSettings settings, System.Uri baseUri)
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader, bool skipJournaledProperties, System.Uri baseUri)
PresentationFramework.dll!System.Windows.Markup.XamlReader.Load(System.Xaml.XamlReader xamlReader, System.Windows.Markup.ParserContext parserContext)
PresentationFramework.dll!System.Windows.Markup.XamlReader.Load(System.Xml.XmlReader reader, System.Windows.Markup.ParserContext parserContext, System.Windows.Markup.XamlParseMode parseMode, bool useRestrictiveXamlReader)
PresentationFramework.dll!System.Windows.Markup.XamlReader.Load(System.IO.Stream stream, System.Windows.Markup.ParserContext parserContext, bool useRestrictiveXamlReader)
ReachFramework.dll!System.Windows.Xps.Packaging.XpsDocument.GetFixedDocumentSequence()
Waf.Writer.Applications.dll!Waf.Writer.Applications.Controllers.PrintController.ShowPrintPreview()
System.Waf.Core.dll!System.Waf.Applications.DelegateCommand..ctor.AnonymousMethod__0(object p)
System.Waf.Core.dll!System.Waf.Applications.DelegateCommand.Execute(object parameter)
PresentationFramework.dll!MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource commandSource, bool userInitiated)
PresentationFramework.dll!System.Windows.Controls.MenuItem.InvokeClickAfterRender(object arg)
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs)
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler)
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl()
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(object obj)
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 172
	at F:\workspace\_work\1\s\src\System.Private.CoreLib\shared\System\Threading\ExecutionContext.cs(172)
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext executionContext, System.Threading.ContextCallback callback, object state)
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke()
WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue()
WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o)
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs)
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler)
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs)
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam)
[Native to Managed Transition]
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame)
PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore)
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window)
Writer.dll!Waf.Writer.Presentation.App.Main()
@stevenbrix stevenbrix added the Bug Product bug (most likely) label Apr 13, 2019
@stevenbrix stevenbrix modified the milestones: 3.0, Preview Apr 13, 2019
@rladuca rladuca added the regression status: This issue is a regression from a previous build or release label May 20, 2019
@grubioe grubioe modified the milestones: Preview, 3.0 May 24, 2019
@stevenbrix
Copy link
Contributor

@jbe2277 can you confirm this is still happening in the latest preview? i just tried this out and it doesn't seem to repro with this SDK/runtime combo:

SDK: 3.0.100-preview6-012105
Microsoft.WindowsDesktop.App 3.0.0-preview6-27728-04

@grubioe grubioe added the 📭 waiting-author-feedback To request more information from author. label Jun 18, 2019
@grubioe grubioe modified the milestones: Preview, 3.0 Jun 18, 2019
@jbartlau
Copy link

jbartlau commented Jun 19, 2019

@stevenbrix I had a repro too, although it might be a different issue as the exception is of a different type. Glad to open separate issue then. I get a NotSupportedException when calling into GetFixedDocumentSequence, Exception details are

System.NotSupportedException
  HResult=0x80131515
  Message=This operation is not supported.
  Source=System.IO.Compression
  StackTrace:
   at System.IO.Compression.DeflateStream.get_Position()
   at System.IO.Packaging.ZipWrappingStream.get_Position()
   at MS.Internal.IO.Packaging.SynchronizingStream.get_Position() in /_/src/Microsoft.DotNet.Wpf/src/shared/MS/Internal/IO/SynchronizingStream.cs:line 207
   at MS.Internal.IO.Packaging.DeobfuscatingStream.Read(Byte[] buffer, Int32 offset, Int32 count) in /_/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/Internal/IO/Packaging/DeobfuscatingStream.cs:line 56
   at MS.Internal.FontCache.FontSource.StreamToByteArray(Stream fontStream) in /_/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/Internal/FontCache/FontSource.cs:line 419
   at MS.Internal.FontCache.FontSource.GetUnmanagedStream() in /_/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/Internal/FontCache/FontSource.cs:line 279
   at MS.Internal.Text.TextInterface.FontFileStream..ctor(IFontSource fontSource)
   at MS.Internal.Text.TextInterface.FontFileLoader.CreateStreamFromKey(Void* fontFileReferenceKey, UInt32 fontFileReferenceKeySize, IntPtr* fontFileStream)

Tested on preview 6. Just let me know if I should open a separate issue for this. I'll then try to minimize my app.

@weltkante
Copy link

@jbartlau definitely a different issue, the non-seekable package streams are a known issue (#585) but your particular scenario wasn't mentioned anywhere yet, probably a good idea to add some details there so it doesn't get missed

@jbartlau
Copy link

@weltkante Thanks, done.

@stevenbrix
Copy link
Contributor

@jbartlau thanks for letting us know! We'll continue the discussion on #585

@ghost
Copy link

ghost commented Jun 25, 2019

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions!

@ghost ghost added the no-recent-activity label Jun 25, 2019
@ghost ghost closed this as completed Jun 28, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Apr 17, 2022
@dipeshmsft dipeshmsft removed the 📭 waiting-author-feedback To request more information from author. label Aug 24, 2022
@ghost ghost removed the no-recent-activity label Aug 24, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Product bug (most likely) needs-updated-estimate This issue needs an updated estimate regression status: This issue is a regression from a previous build or release
Projects
None yet
Development

No branches or pull requests

8 participants