dotnet/wpf · error · ArgumentException

stylusPointProperty

Error message

stylusPointProperty

What it means

StylusPointDescription.GetPropertyInfo(guid) looks up a StylusPointPropertyInfo by its property Guid and throws a bare ArgumentException("stylusPointProperty") when the Guid is not part of this description. The parameter-name string is used as the message, so the message itself is just 'stylusPointProperty' — the actual problem is an unknown/unregistered property ID.

Solutions

  1. Before calling, check description.HasProperty(guid) (or IndexOf via internal API) and handle absence.
  2. Ensure the property Guid was included in the StylusPointDescription when it was constructed or in the source description passed to GetStylusPointDescription.
  3. Use StylusPoint.GetStylusPointPropertyInfo / the description returned by the StylusPoints collection rather than a hand-built description.
  4. Wrap in try-catch for ArgumentException when the property is optional.

Example fix

// before
var info = description.GetPropertyInfo(myCustomPropertyId); // throws if absent
// after
if (description.GetStylusPointProperties().Any(p => p.Id == myCustomPropertyId))
{
    var info = description.GetPropertyInfo(myCustomPropertyId);
}
Defensive patterns

Strategy: try-catch

Validate before calling

bool exists = description.GetStylusPointProperties().Any(p => p.Id == guid);

Try / catch

try { var info = description.GetPropertyInfo(guid); }
catch (ArgumentException) { info = null; /* property not in this description */ }

Prevention

When it happens

Trigger: Calling GetPropertyInfo with a Guid that was never added to the StylusPointDescription, e.g. a custom property Guid or a button Guid not included when the description was built.

Common situations: Reading a custom packet property from a StylusPoint whose description was changed (Reformat) to drop that property; querying a button property on a description built without buttons; using a hardcoded Guid that differs from the device's reported Guid.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointDescription.cs:151

        /// </summary>
        /// <param name="stylusPointProperty">stylusPointProperty</param>
        public StylusPointPropertyInfo GetPropertyInfo(StylusPointProperty stylusPointProperty)
        {
            ArgumentNullException.ThrowIfNull(stylusPointProperty);
            return GetPropertyInfo(stylusPointProperty.Id);
        }

        /// <summary>
        /// GetPropertyInfo
        /// </summary>
        /// <param name="guid">guid</param>
        internal StylusPointPropertyInfo GetPropertyInfo(Guid guid)
        {
            int index = IndexOf(guid);
            if (-1 == index)
            {
                //we didn't find it
                throw new ArgumentException("stylusPointProperty");
            }
            return _stylusPointPropertyInfos[index];
        }

        /// <summary>
        /// Returns the index of the given StylusPointProperty by ID, or -1 if none is found
        /// </summary>
        internal int GetPropertyIndex(Guid guid)
        {
            return IndexOf(guid);
        }

        /// <summary>
        /// GetStylusPointProperties
        /// </summary>
        public ReadOnlyCollection<StylusPointPropertyInfo> GetStylusPointProperties()
        {
            return new ReadOnlyCollection<StylusPointPropertyInfo>(_stylusPointPropertyInfos);

View on GitHub (pinned to 81131a70a4)