dotnet/wpf · error · InvalidOperationException
Timing_SeekDestinationIndefinite
Timing_SeekDestinationIndefinite
Error message
SR.Timing_SeekDestinationIndefinite (Timing_SeekDestinationIndefinite)
What it means
ClockController.Seek with TimeSeekOrigin.Duration adds the offset to the clock's resolved duration. If that duration is Forever or not yet resolved (no TimeSpan), there is no numeric duration to be relative to, so WPF throws InvalidOperationException (Timing_SeekDestinationIndefinite).
Solutions
- Use TimeSeekOrigin.Begin instead of Duration when the duration may be indefinite
- Ensure the timeline has a concrete TimeSpan Duration before seeking relative to Duration
- Check _owner.ResolvedDuration.HasTimeSpan before seeking and branch accordingly
- Start the clock (Begin) and let it resolve duration before performing duration-relative seeks
Example fix
// before
if (duration == Duration.Forever)
controller.Seek(TimeSpan.FromSeconds(2), TimeSeekOrigin.Duration); // throws
// after
if (controller != null)
controller.Seek(TimeSpan.FromSeconds(2), TimeSeekOrigin.Begin); // relative to start always works Defensive patterns
Strategy: validation
Validate before calling
if (origin == TimeSeekOrigin.Duration && !clock.ResolvedDuration.HasTimeSpan)
origin = TimeSeekOrigin.Begin; // safe fallback Try / catch
try { controller.Seek(offset, TimeSeekOrigin.Duration); }
catch (InvalidOperationException) { controller.Seek(offset, TimeSeekOrigin.Begin); } Prevention
- Avoid Duration="Forever" on timelines you need to seek relative to Duration
- Default to TimeSeekOrigin.Begin for indefinite timelines
- Start (Begin) the clock and allow resolution before duration-relative seeks
When it happens
Trigger: controller.Seek(offset, TimeSeekOrigin.Duration) where the owning timeline's ResolvedDuration has no TimeSpan — Duration="Forever", or the clock hasn't been started/resolved yet (duration still Automatic/unresolved).
Common situations: Seeking relative to Duration on a storyboard declared with Duration="Forever" or with no explicit Duration before resolution; interactive seek logic invoked before Begin/first tick resolved the clock.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SR.Timing_InvalidArgNonNegative
- SR.Timing_NotTimeSpan
- Timing_SeekDestinationAmbiguousDueToSlip
- Timing_SeekDestinationNegative
- Animation_AnimationTimelineTypeMismatch
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/291231ce06ca388b.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/ClockController.cs:167
// IF YOU CHANGE THIS CODE:
// This code is very similar to that in SeekAlignedToLastTick and is duplicated
// in each method so that exceptions will be thrown from the public
// method the user has called. You probably need to change both methods.
if (!TimeEnumHelper.IsValidTimeSeekOrigin(origin))
{
throw new InvalidEnumArgumentException(SR.Format(SR.Enum_Invalid, "TimeSeekOrigin"));
}
if (origin == TimeSeekOrigin.Duration)
{
Duration duration = _owner.ResolvedDuration;
if (!duration.HasTimeSpan)
{
// Can't seek relative to the Duration if it has been specified as Forever or if
// it has not yet been resolved.
throw new InvalidOperationException(SR.Timing_SeekDestinationIndefinite);
}
else
{
offset += duration.TimeSpan;
}
}
// Any offset greater than zero is OK here. If it's past the effective
// duration it means execute the FillBehavior.
if (offset < TimeSpan.Zero)
{
throw new InvalidOperationException(SR.Timing_SeekDestinationNegative);
}
_owner.InternalSeek(offset);
}
/// <summary>View on GitHub (pinned to 81131a70a4)