Skip to content

XpsDocument.GetFixedDocumentSequence throws an exception #575

Closed
@jbe2277

Description

@jbe2277
  • .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:

  • Clone https://github.com/jbe2277/waf.git
  • Checkout the netcoreapp3.0 branch
  • Open System.Waf.sln in VS 2019.
  • Set Samples/Writer/Writer.Presentation as start-up project
  • Start the application and click on New.
  • Click on Ribbon menu and then on Print preview.

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()

Metadata

Metadata

Assignees

Labels

BugProduct bug (most likely)needs-updated-estimateThis issue needs an updated estimateregressionstatus: This issue is a regression from a previous build or release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions