dotnet/wpf · error · ArgumentException

SR.InvalidPoint

Error message

SR.InvalidPoint

What it means

An InkCanvas public API (point-taking method) validates that the supplied Point contains only finite values. A Point with NaN or Infinity in X or Y is rejected with an ArgumentException (SR.InvalidPoint). Such coordinates cannot participate in ink geometry or layout math.

Solutions

  1. Validate the Point for NaN/Infinity before passing it (double.IsFinite on X and Y)
  2. Fix the upstream computation producing non-finite coordinates (guard divisions, initialize fields)
  3. Clamp or substitute a default finite point when a computation fails

Example fix

// before
inkCanvas.SomePointMethod(new Point(x, y)); // x/y may be NaN
// after
if (double.IsFinite(x) && double.IsFinite(y)) { inkCanvas.SomePointMethod(new Point(x, y)); }
Defensive patterns

Strategy: validation

Validate before calling

bool IsValid(Point p) => double.IsFinite(p.X) && double.IsFinite(p.Y);

Type guard

bool IsFinitePoint(Point p) => !double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsInfinity(p.X) && !double.IsInfinity(p.Y);

Try / catch

try { inkCanvas.PointMethod(point); } catch (ArgumentException ex) when (ex.ParamName == "point") { /* reject or sanitize the point */ }

Prevention

When it happens

Trigger: Calling InkCanvas APIs that take a Point (e.g. stroke positioning/editing methods) with a Point whose X or Y is NaN, +Infinity, or -Infinity — often from uninitialized doubles, division by zero, or failed hit-test results.

Common situations: Computing points from transforms with zero determinant; deserializing coordinates where NaN slips in; default/uninitialized struct fields producing NaN.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/81721ededaf95836. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/InkCanvas.cs:1842

            // No need to call VerifyAccess since this call is forwarded.

            // We always paste the data to the default location which is (0,0).
            Paste(new Point(c_pasteDefaultLocation, c_pasteDefaultLocation));
        }

        /// <summary>
        /// Paste the contents of the clipboard to the specified location in the InkCanvas
        /// </summary>
        public void Paste(Point point)
        {
            VerifyAccess();

            if (double.IsNaN(point.X) ||
                double.IsNaN(point.Y) ||
                Double.IsInfinity(point.X)||
                Double.IsInfinity(point.Y) )
            {
                    throw new ArgumentException(SR.InvalidPoint, nameof(point));
            }


            //
            // only do this if the user is not editing (input active)
            // or we will violate a dispatcher lock
            //
            if (!_editingCoordinator.UserIsEditing)
            {
                IDataObject dataObj = null;
                try
                {
                    dataObj = Clipboard.GetDataObject();
                }
                catch (ExternalException)
                {
                    //harden against ExternalException
                    return;

View on GitHub (pinned to 81131a70a4)