dotnet/wpf · error · ArgumentNullException
Point3DKeyFrameCollection
Error message
Point3DKeyFrameCollection[{0}] What it means
The Point3DKeyFrameCollection indexer setter throws ArgumentNullException when a null key frame is assigned. The paramName is the formatted string "Point3DKeyFrameCollection[index]" identifying the position.
Solutions
- Null-check values before index assignment
- Use Add with validated non-null frames
- Call RemoveAt to remove a frame instead of assigning null
Example fix
// before keyFrames[2] = null; // after if (keyFrames.Count > 2) keyFrames.RemoveAt(2);
Defensive patterns
Strategy: validation
Validate before calling
if (frame == null) throw new ArgumentException($"Point3DKeyFrameCollection[{index}] requires a non-null frame");
collection[index] = frame; Type guard
bool IsValidFrame(Point3DKeyFrame f) => f != null;
Try / catch
try { collection[index] = frame; }
catch (ArgumentNullException ex) when (ex.ParamName?.StartsWith("Point3DKeyFrameCollection[") == true) { /* assign a valid frame or remove the slot */ } Prevention
- Null-check frames before index assignment
- Use RemoveAt to clear slots
- Filter null entries from generated frame collections
When it happens
Trigger: Executing collection[index] = null on a Point3DKeyFrameCollection.
Common situations: Data-driven frame generation producing nulls; clearing slots by assigning null.
Related errors
- DoubleKeyFrameCollection
- Int16KeyFrameCollection
- MatrixKeyFrameCollection
- ObjectKeyFrameCollection
- [[instance.TypeName]]KeyFrameCollection
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/b1b9727a6d12c479.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Point3DKeyFrameCollection.cs:466
}
}
/// <summary>
/// Gets or sets the Point3DKeyFrame at a given index.
/// </summary>
public Point3DKeyFrame this[int index]
{
get
{
ReadPreamble();
return _keyFrames[index];
}
set
{
if (value == null)
{
throw new ArgumentNullException(String.Format(CultureInfo.InvariantCulture, "Point3DKeyFrameCollection[{0}]", index));
}
WritePreamble();
if (value != _keyFrames[index])
{
OnFreezablePropertyChanged(_keyFrames[index], value);
_keyFrames[index] = value;
Debug.Assert(_keyFrames[index] != null);
WritePostscript();
}
}
}
#endregion
}View on GitHub (pinned to 81131a70a4)