dotnet/wpf · error · ArgumentException
SR.IncompatibleStylusPointDescriptions
Error message
SR.IncompatibleStylusPointDescriptions
What it means
RawStylusInput.SetStylusPoints replaces the stylus point collection carried by a raw stylus input packet. The new collection's StylusPointDescription must be compatible (same required point properties) with the description of the underlying RawStylusInputReport; WPF throws this ArgumentException otherwise because mixing descriptions would corrupt downstream StylusPlugIn processing.
Solutions
- Base replacement points on the existing description: clone or copy the incoming StylusPoints and modify values rather than constructing a new StylusPointCollection with a default/new description
- Pass stylusPoints.Description (the incoming collection's description) when creating the new StylusPointCollection
- Call StylusPointDescription.AreCompatible(newDesc, oldDesc) in debug code to verify compatibility before calling SetStylusPoints
Example fix
// before var newPts = new StylusPointCollection(); newPts.Add(new StylusPoint(x, y)); rawStylusInput.SetStylusPoints(newPts); // after StylusPointCollection newPts = new StylusPointCollection(stylusPoints.Description); newPts.Add(new StylusPoint(x, y)); rawStylusInput.SetStylusPoints(newPts);
Defensive patterns
Strategy: validation
Validate before calling
if (!StylusPointDescription.AreCompatible(newPoints.Description, incoming.Description)) throw new InvalidOperationException("Incompatible StylusPointDescription"); Try / catch
try { rawStylusInput.SetStylusPoints(newPoints); } catch (ArgumentException ex) when (ex.ParamName == "stylusPoints") { /* fall back to original points */ } Prevention
- Always construct replacement StylusPointCollections from the incoming collection's Description
- Never build points with the default description inside StylusPlugIn handlers
- Assert AreCompatible in debug builds
When it happens
Trigger: Calling SetStylusPoints with a StylusPoints collection whose Description was built with a different set of optional properties (e.g. added/removed StylusPointPropertyInfo like Pressure, TangentPressure, tilt) than the description captured in the report that raised the event.
Common situations: A StylusPlugIn.OnStylusDown/OnStylusMove handler creates new StylusPoints from scratch (default description) instead of reusing stylusPoints.Description from the incoming event, so on tablet hardware with extra packet properties the descriptions do not match.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- SR.InvalidIsButtonForId
- SR.InvalidIsButtonForId2
- SR.InvalidStylusPointDescription
- SR.InvalidStylusPointDescriptionButtonsMustBeLast
- SR.InvalidStylusPointDescriptionDuplicatesFound
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/015665076a1b4410.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/RawStylusInput.cs:103
return _stylusPoints.Clone(transform, _stylusPoints.Description);
}
}
/// <summary>
/// Replaces the StylusPoints.
/// </summary>
/// <remarks>
/// Callers must have Unmanaged code permission to call this API.
/// </remarks>
/// <param name="stylusPoints">stylusPoints</param>
public void SetStylusPoints(StylusPointCollection stylusPoints)
{
ArgumentNullException.ThrowIfNull(stylusPoints);
if (!StylusPointDescription.AreCompatible( stylusPoints.Description,
_report.StylusPointDescription))
{
throw new ArgumentException(SR.IncompatibleStylusPointDescriptions, nameof(stylusPoints));
}
if (stylusPoints.Count == 0)
{
throw new ArgumentException(SR.Stylus_StylusPointsCantBeEmpty, nameof(stylusPoints));
}
_stylusPoints = stylusPoints.Clone();
}
/// <summary>
/// Returns the RawStylusInputCustomDataList used to notify plugins before
/// PreviewStylus event has been processed by application.
/// </summary>
public void NotifyWhenProcessed(object callbackData)
{
if (_currentNotifyPlugIn == null)
{
throw new InvalidOperationException(SR.Stylus_CanOnlyCallForDownMoveOrUp);View on GitHub (pinned to 81131a70a4)