#11983·wpf

XPS serialization writes ArcSegment.RotationAngle with the current culture (VisualSerializer.cs), decimal comma yields invalid page markup

Author: piet0815Created Sep 30, 2026Updated Sep 30, 2026

Description

When a FixedDocument containing an elliptical arc with a fractional rotation angle is serialized to XPS (XpsDocumentWriter.Write, and the XPS path used by PrintDialog.PrintDocument) on a thread whose culture uses a decimal comma, the rotation angle is written with the comma, e.g. -168,65.

In the XPS path mini-language the comma is a separator, so the arc segment A rx,ry angle isLargeArc sweep x,ygets the wrong number of parameters and the page markup is invalid.

All other numbers of the same path (radii, points) are written culture-invariantly; only the rotation angle is affected.

Observed output (same path, only the thread culture differs):

de-DE: M0,0L39,16A207.14,193.14 -168,65 0 0 124,33L172,33
en-US: M0,0L39,16A207.14,193.14 -168.65 0 0 124,33L172,33

In our application this surfaces when printing to "Microsoft Print to PDF" with a de-DE / pl-PL culture:IXpsOMObjectFactory.CreatePageFromStream fails with COMException 0x8052000C (XPS_E_INVALID_MARKUP), WPF aborts the job without throwing to the caller, and the output file stays at 0 bytes. The same content prints correctly when the thread culture is InvariantCulture.

Root cause

src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualSerializer.cs, in the ArcSegment branch of the path data builder (line 1310 on main at the time of writing):

rslt.Append('A');
AppendPoint(rslt, new Point(s.Width * map.M11, s.Height * map.M22), Matrix.Identity);
rslt.Append(' ');
rslt.Append(a.RotationAngle);      // StringBuilder.Append(double) uses CultureInfo.CurrentCulture
rslt.Append(' ');

The surrounding code consistently uses CultureInfo.InvariantCulture (AppendPoint, the matrix and viewbox formatting, WriteAttr). This is the only StringBuilder.Append of a floating-point value in that file that does not.

Suggested fix

rslt.Append(a.RotationAngle.ToString(CultureInfo.InvariantCulture));

(Other serializers in the same file additionally go through CheckFloat; it may be worth applying it here as well.)

Reproduction Steps

Attached is a minimal console project (ArcCultureRepro, .NET 10, WPF). ArcCultureRepro.zip

  1. dotnet run -c Release -- de-DE
  2. The program serializes a one-page FixedDocument with a single Path(M 0,0 L 39,16 A 207.139,193.142 -168.65 0 0 124,33 L 172,33) to an .xps file and prints the arc as it appears in the generated page markup.
  3. Compare with dotnet run -c Release -- en-US.

Optional: add --print to send the same document through PrintDialog.PrintDocument to "Microsoft Print to PDF".

Expected behavior

The rotation angle is written culture-invariantly (-168.65) regardless of the thread culture.

Actual behavior

The rotation angle is written with the thread culture (-168,65), which produces invalid XPS markup.

Regression?

No response

Known Workarounds

Set CultureInfo.CurrentCulture = CultureInfo.InvariantCulture for the duration of the print/serialization call and restore it afterwards.

Impact

When printing to "Microsoft Print to PDF" with a de-DE / pl-PL culture, WPF aborts the job without throwing to the caller, and the output file stays at 0 bytes.

Configuration

  • .NET 10.0.12 (WindowsDesktop runtime)
  • Windows 11
  • Thread culture de-DE (customer: pl-PL)

Other information

No response