dotnet/wpf · error · ArgumentNullException
Int64KeyFrameCollection
Error message
Int64KeyFrameCollection[{0}] What it means
The Int64KeyFrameCollection indexer setter throws ArgumentNullException with message 'Int64KeyFrameCollection[{index}]' when null is assigned at an index. Null key frames are invalid collection items.
Solutions
- Null-check frames before indexer assignment.
- Ensure frame factory/lookup code never returns null without handling.
- Use KeyFrames.Add with validated instances.
Example fix
// before keyFrames[i] = frames[i]; // frames[i] may be null // after if (frames[i] != null) keyFrames[i] = frames[i];
Defensive patterns
Strategy: type-guard
Validate before calling
if (frame == null)
throw new InvalidOperationException($"No key frame available for index {index}; refusing to insert null into Int64KeyFrameCollection."); Type guard
bool IsValidFrame(Int64KeyFrame f) => f != null;
Try / catch
try { keyFrames[index] = frame; }
catch (ArgumentNullException ex) when (ex.Message.Contains("Int64KeyFrameCollection[")) {
// substitute a valid key frame or log and skip
} Prevention
- Guard frame-producing code against null returns
- Validate generated key frames before collection insertion
- Test collection construction paths with edge-case data
When it happens
Trigger: Executing int64KeyFrames[index] = null; on an Int64KeyFrameCollection.
Common situations: Programmatic collection building with a null frame from a factory or lookup; data-driven frame generation failing silently.
Related errors
- Int32KeyFrameCollection
- PointKeyFrameCollection
- RectKeyFrameCollection
- ColorKeyFrameCollection
- DecimalKeyFrameCollection
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/0ec3bc786b13a251.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Int64KeyFrameCollection.cs:466
}
}
/// <summary>
/// Gets or sets the Int64KeyFrame at a given index.
/// </summary>
public Int64KeyFrame this[int index]
{
get
{
ReadPreamble();
return _keyFrames[index];
}
set
{
if (value == null)
{
throw new ArgumentNullException(String.Format(CultureInfo.InvariantCulture, "Int64KeyFrameCollection[{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)