{"record":{"id":"278dc6bc17aa9f79","repo":"peass-ng/PEASS-ng","slug":"resources-error-triggerendbeforestart","errorCode":null,"errorMessage":"Resources.Error_TriggerEndBeforeStart","messagePattern":"Resources\\.Error_TriggerEndBeforeStart","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/Trigger.cs","lineNumber":2407,"sourceCode":"                    v2Trigger.GetType().InvokeMember(key, System.Reflection.BindingFlags.SetProperty, null, v2Trigger, new[] { o });\n                }\n                catch (System.Reflection.TargetInvocationException tie) when (tie.InnerException != null) { throw tie.InnerException; }\n                catch { /* ignored */ }\n            }\n            unboundValues.Clear();\n            unboundValues = null;\n\n            repititionPattern = new RepetitionPattern(this);\n            repititionPattern.Bind();\n        }\n\n        /// <summary>Assigns the unbound TriggerData structure to the V1 trigger instance.</summary>\n        internal void SetV1TriggerData()\n        {\n            if (v1TriggerData.MinutesInterval != 0 && v1TriggerData.MinutesInterval >= v1TriggerData.MinutesDuration)\n                throw new ArgumentException(\"Trigger.Repetition.Interval must be less than Trigger.Repetition.Duration under Task Scheduler 1.0.\");\n            if (v1TriggerData.EndDate <= v1TriggerData.BeginDate)\n                throw new ArgumentException(Resources.Error_TriggerEndBeforeStart);\n            if (v1TriggerData.BeginDate == DateTime.MinValue)\n                v1TriggerData.BeginDate = DateTime.Now;\n            v1Trigger?.SetTrigger(ref v1TriggerData);\n            System.Diagnostics.Debug.WriteLine(v1TriggerData);\n        }\n\n        /// <summary>Checks the bind value for any conversion.</summary>\n        /// <param name=\"key\">The key (property) name.</param>\n        /// <param name=\"o\">The value.</param>\n        protected virtual void CheckBindValue(string key, ref object o)\n        {\n            if (o is TimeSpan ts)\n                o = Task.TimeSpanToString(ts);\n            if (o is DateTime dt)\n            {\n                if (key == \"EndBoundary\" && dt == DateTime.MaxValue || key == \"StartBoundary\" && dt == DateTime.MinValue)\n                    o = null;\n                else","sourceCodeStart":2389,"sourceCodeEnd":2425,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/Trigger.cs#L2389-L2425","documentation":"SetV1TriggerData throws ArgumentException with the localized resource Error_TriggerEndBeforeStart when the trigger's EndDate is earlier than or equal to its BeginDate. A v1 trigger must end after it starts, so the library refuses to bind such trigger data.","triggerScenarios":"Creating a trigger with StartBoundary after EndBoundary, or both equal; computing dates dynamically where EndDate ends up <= BeginDate (e.g. zero-length window or timezone/locale parsing issues).","commonSituations":"Dynamic schedules where EndDate = StartDate + duration with duration=0; strings parsed with the wrong culture flipping day/month so EndDate < StartDate.","solutions":["Ensure EndBoundary > StartBoundary before registering the trigger","Validate parsed DateTime values and culture when building dates from strings","Clamp/extend EndDate to at least BeginDate + minimal duration"],"exampleFix":"// before\ntrigger.StartBoundary = start;\ntrigger.EndBoundary = start; // equals start -> throws\n// after\ntrigger.StartBoundary = start;\ntrigger.EndBoundary = start > DateTime.Now ? start.AddDays(1) : DateTime.Now.AddDays(1);","handlingStrategy":"validation","validationCode":"if (trigger.EndBoundary <= trigger.StartBoundary)\n    trigger.EndBoundary = trigger.StartBoundary.AddDays(1);","typeGuard":null,"tryCatchPattern":"try { folder.RegisterTaskDefinition(name, def, ...); }\ncatch (ArgumentException ex) when (ex.Message == Resources.Error_TriggerEndBeforeStart) { /* fix boundaries and retry */ }","preventionTips":["Validate EndBoundary > StartBoundary at config load time","Use culture-invariant parsing (DateTime.TryParseExact/ISO 8601) for schedule strings","Never allow zero-length schedule windows"],"tags":["task-scheduler","trigger","date-validation"],"backgroundTag":"trigger-end-before-start","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}