{"record":{"id":"291231ce06ca388b","repo":"dotnet/wpf","slug":"timing-seekdestinationindefinite","errorCode":"Timing_SeekDestinationIndefinite","errorMessage":"SR.Timing_SeekDestinationIndefinite (Timing_SeekDestinationIndefinite)","messagePattern":"SR\\.Timing_SeekDestinationIndefinite \\(Timing_SeekDestinationIndefinite\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/ClockController.cs","lineNumber":167,"sourceCode":"            // IF YOU CHANGE THIS CODE:\n            // This code is very similar to that in SeekAlignedToLastTick and is duplicated\n            // in each method so that exceptions will be thrown from the public \n            // method the user has called. You probably need to change both methods.\n\n            if (!TimeEnumHelper.IsValidTimeSeekOrigin(origin))\n            {\n                throw new InvalidEnumArgumentException(SR.Format(SR.Enum_Invalid, \"TimeSeekOrigin\"));\n            }\n\n            if (origin == TimeSeekOrigin.Duration)\n            {\n                Duration duration = _owner.ResolvedDuration;\n\n                if (!duration.HasTimeSpan)\n                {\n                    // Can't seek relative to the Duration if it has been specified as Forever or if\n                    // it has not yet been resolved.\n                    throw new InvalidOperationException(SR.Timing_SeekDestinationIndefinite);\n                }\n                else\n                {\n                    offset += duration.TimeSpan;\n                }\n            }\n\n            // Any offset greater than zero is OK here. If it's past the effective\n            // duration it means execute the FillBehavior.\n            if (offset < TimeSpan.Zero)\n            {\n                throw new InvalidOperationException(SR.Timing_SeekDestinationNegative);\n            }\n\n            _owner.InternalSeek(offset);\n        }\n\n        /// <summary>","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/ClockController.cs#L149-L185","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nif (duration == Duration.Forever)\n    controller.Seek(TimeSpan.FromSeconds(2), TimeSeekOrigin.Duration); // throws\n// after\nif (controller != null)\n    controller.Seek(TimeSpan.FromSeconds(2), TimeSeekOrigin.Begin); // relative to start always works","handlingStrategy":"validation","validationCode":"if (origin == TimeSeekOrigin.Duration && !clock.ResolvedDuration.HasTimeSpan)\n    origin = TimeSeekOrigin.Begin; // safe fallback","typeGuard":null,"tryCatchPattern":"try { controller.Seek(offset, TimeSeekOrigin.Duration); }\ncatch (InvalidOperationException) { controller.Seek(offset, TimeSeekOrigin.Begin); }","preventionTips":["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"],"tags":["wpf","animation","seek","duration"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}