XpsDocumentWriter.SaveAsXaml - BitmapMetadata is not available on BitmapImage
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: 6.0 (guess all versions)
* Visual Studio 2019, 2022, 2022 preview
**Problem description:**
Attaching WinDbg Preview to a process I see lots of System.NotSupportedException happening with message "BitmapMetadata is not available on BitmapImage"
Why throw instead of checking if metadata is supported or not ?
**Actual behavior:**
`(50e8.3f8): CLR exception - code e0434352 (first chance)
Exception object: 000001f93a3e2b20
Exception type: System.NotSupportedException
Message: BitmapMetadata is not available on BitmapImage.
InnerException:
StackTrace (generated):
StackTraceString:
HResult: 80131515
OS Thread Id: 0x3f8 (19)
Child SP IP Call Site
000000ED8423BC68 00007ff8a4b44f69 [HelperMethodFrame: 000000ed8423bc68]
000000ED8423BD60 00007ff831597011 System.Windows.Media.Imaging.BitmapImage.get_Metadata()
000000ED8423BDA0 00007ff82e52057c System.Windows.Media.Imaging.BitmapFrame.Create(System.Windows.Media.Imaging.BitmapSource)
000000ED8423BDF0 00007ff82e520442 System.Windows.Xps.Serialization.ImageSourceTypeConverter.ReEncodeImage(System.Windows.Media.Imaging.BitmapSource, System.Windows.Media.Imaging.BitmapEncoder, System.IO.Stream)
000000ED8423BEB0 00007ff82e517e98 System.Windows.Xps.Serialization.ImageSourceTypeConverter.ConvertTo(System.ComponentModel.ITypeDescriptorContext, System.Globalization.CultureInfo, System.Object, System.Type)
000000ED8423BF50 00007ff82e517744 System.Windows.Xps.Serialization.VisualSerializer.WriteBitmap(System.String, System.Windows.Media.ImageSource)
000000ED8423C040 00007ff82e515dab System.Windows.Xps.Serialization.VisualSerializer.BrushToString(System.Windows.Media.Brush, System.Windows.Rect)
000000ED8423C560 00007ff82e514da4 System.Windows.Xps.Serialization.VisualSerializer.FindBrush(System.Windows.Media.Brush, System.Windows.Rect)
000000ED8423C5E0 00007ff82df723bc System.Windows.Xps.Serialization.VisualSerializer.WriteBrush(System.String, System.Windows.Media.Brush, System.Windows.Rect)
000000ED8423C640 00007ff82df70e78 System.Windows.Xps.Serialization.VisualSerializer.System.Windows.Xps.Serialization.IMetroDrawingContext.DrawGeometry(System.Windows.Media.Brush, System.Windows.Media.Pen, System.Windows.Media.Geometry)
000000ED8423C810 00007ff82e513f55 System.Windows.Xps.Serialization.DrawingContextFlattener.DrawImage(System.Windows.Media.ImageSource, System.Windows.Rect)
000000ED8423C8A0 00007ff82df6b4ef System.Windows.Xps.Serialization.VisualTreeFlattener.DrawingWalk(System.Windows.Media.Drawing, System.Windows.Media.Matrix)
000000ED8423CB80 00007ff82df6b7e8 System.Windows.Xps.Serialization.VisualTreeFlattener.DrawingWalk(System.Windows.Media.Drawing, System.Windows.Media.Matrix)
000000ED8423CE60 00007ff82df6b7e8 System.Windows.Xps.Serialization.VisualTreeFlattener.DrawingWalk(System.Windows.Media.Drawing, System.Windows.Media.Matrix)
000000ED8423D140 00007ff82df6b7e8 System.Windows.Xps.Serialization.VisualTreeFlattener.DrawingWalk(System.Windows.Media.Drawing, System.Windows.Media.Matrix)
000000ED8423D420 00007ff82e46fa7b System.Windows.Xps.Serialization.VisualTreeFlattener.StartVisual(System.Windows.Media.Visual)
000000ED8423D930 00007ff82e4f3da0 System.Windows.Xps.Serialization.ReachVisualSerializer.SerializeTree(System.Windows.Media.Visual, System.Xml.XmlWriter, System.Xml.XmlWriter)
000000ED8423D9E0 00007ff82e4f377a System.Windows.Xps.Serialization.ReachUIElementCollectionSerializer.SerializeUIElements(System.Windows.Xps.Serialization.SerializableObjectContext)
000000ED8423DA30 00007ff82e4eb27b System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(System.Windows.Xps.Serialization.SerializablePropertyContext)
000000ED8423DA70 00007ff82e4eb1a3 System.Windows.Xps.Serialization.ReachSerializer.SerializeProperties(System.Windows.Xps.Serialization.SerializableObjectContext)
000000ED8423DAB0 00007ff82e4f104e System.Windows.Xps.Serialization.FixedPageSerializer.PersistObjectData(System.Windows.Xps.Serialization.SerializableObjectContext)
000000ED8423DB90 00007ff82e4bf022 System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(System.Object)
000000ED8423DBD0 00007ff82e4bf022 System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(System.Object)
000000ED8423DC10 00007ff82e4efdb5 System.Windows.Xps.Serialization.ReachPageContentCollectionSerializer.SerializePageContent(System.Object)
000000ED8423DC60 00007ff82e53b75a System.Windows.Xps.Serialization.ReachPageContentCollectionSerializer.SerializePageContents(System.Windows.Xps.Serialization.SerializableObjectContext)
000000ED8423DCB0 00007ff82e4eb27b System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(System.Windows.Xps.Serialization.SerializablePropertyContext)
000000ED8423DCF0 00007ff82e4eb1a3 System.Windows.Xps.Serialization.ReachSerializer.SerializeProperties(System.Windows.Xps.Serialization.SerializableObjectContext)
000000ED8423DD30 00007ff82e53ae35 System.Windows.Xps.Serialization.FixedDocumentSerializer.PersistObjectData(System.Windows.Xps.Serialization.SerializableObjectContext)
000000ED8423DD80 00007ff82e4bf022 System.Windows.Xps.Serialization.ReachSerializer.SerializeObject(System.Object)
000000ED8423DDC0 00007ff82e539ab4 System.Windows.Xps.Serialization.XpsSerializationManager.SaveAsXaml(System.Object)
000000ED8423DE20 00007ff82e5397ef System.Windows.Xps.XpsDocumentWriter.SaveAsXaml(System.Object, Boolean)`
**Expected behavior:**
Looks like this is by design: https://stackoverflow.com/a/17027474/187650
Though, would be much nicer to see if metadata is supported instead of throwing...
Contributor guide
Assessment
This issue has not been assessed yet.