Repository navigation
Open
Labels
InvestigateRequires further investigation by the WPF team.
Milestone
Description
I'm seeing issues with XamlReader.Load. They come via WPF but it may be that the root problem is actually in System.IO.Compression.
This is code that works in .NET 4.X but fails in .NET 5 Preview 5 & 6.
My code is much like this:
ParserContext parserContext = new ParserContext();
parserContext.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
parserContext.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
parserContext.BaseUri = new Uri("pack://" + _documentExporter.PackageUri.AbsoluteUri.Replace('/', ',') + "/");
Canvas canvas = (Canvas)XamlReader.Load(xmlStream, parserContext); // *** Exception Here ***
The exception that is thrown is XamlParseException but the inner exception is from System.IO.Compression,
System.Windows.Markup.XamlParseException: ''Failed to create a 'Color' from the text 'ContextColor /Resources/dc1d82f7-39c9-4539-a5fe-f0cffc7db8b6.icc 1,.81910431,.75130844,.63895631,.92820632'.' Line number '1' and line position '384'.'
InnerException
"Entries cannot be opened multiple times in Update mode."
Source "System.IO.Compression" string
at System.IO.Compression.ZipArchiveEntry.OpenInUpdateMode()
at System.IO.Compression.ZipArchiveEntry.Open()
at System.IO.Packaging.ZipStreamManager.Open(ZipArchiveEntry zipArchiveEntry, FileMode streamFileMode, FileAccess streamFileAccess)
at System.IO.Packaging.ZipPackagePart.GetStreamCore(FileMode streamFileMode, FileAccess streamFileAccess)
at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access)
at MS.Internal.IO.Packaging.PackagePartExtensions.GetSeekableStream(PackagePart packPart, FileMode mode, FileAccess access)
at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream()
at System.IO.Packaging.PackWebResponse.GetResponseStream()
at System.Windows.Media.ColorContext.Initialize(Uri profileUri, Boolean isStandardProfileUriNotFromUser)
at System.Windows.Media.Color.FromProfile(Uri profileUri)
at System.Windows.Media.Color.FromAValues(Single a, Single[] values, Uri profileUri)
at MS.Internal.Parsers.ParseContextColor(String trimmedColor, IFormatProvider formatProvider, ITypeDescriptorContext context)
at MS.Internal.Parsers.ParseColor(String color, IFormatProvider formatProvider, ITypeDescriptorContext context)
at System.Windows.Media.ColorConverter.ConvertFrom(ITypeDescriptorContext td, CultureInfo ci, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateObjectWithTypeConverter(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
at System.Xaml.XamlObjectWriter.Logic_CreateFromValue(ObjectWriterContext ctx, XamlValueConverter`1 typeConverter, Object value, XamlMember property, String targetName, IAddLineInfo lineInfo)
Does this look like a known issue or does it need more detail?
Jos
Reacted by lindexi and Irina pykhova
Metadata
Metadata
Assignees
Labels
InvestigateRequires further investigation by the WPF team.
Activity
lindexi commentedon Jul 1, 2020
What is your
_documentExporter.PackageUrivalue ?josvernon commentedon Jul 1, 2020
The BaseUri property here is,
pack://urn:x-websupergoo:xpspackage:f008dc38-9134-4dbd-8f3a-1d9c0b35b60c.xps/
This matches a previous call to,
PackageStore.AddPackage(PackageUri, _package);
Using a PackageUri of,
urn:x-websupergoo:xpspackage:f008dc38-9134-4dbd-8f3a-1d9c0b35b60c.xps
josvernon commentedon Jul 6, 2020
Do you need more from me?
bgrainger commentedon Jul 23, 2022
This is not the same cause as #6842. This crash can very likely be fixed by disposing
profileStreamafter callingFromStreamhere:wpf/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs
Lines 560 to 561 in c8742b5
The bug is that
ColorContext.Initializeleaks theStreamit opens.miloush commentedon Jul 27, 2022
@bgrainger good catch, do you want to make a PR?
bgrainger commentedon Jul 29, 2022
I could, but I don't have a self-contained repro of the problem to verify the fix.