{"record":{"id":"7aed4a929a22fc63","repo":"winsw/winsw","slug":"start-mode-in-xml-must-be-one-of-the-following","errorCode":null,"errorMessage":"Start mode in XML must be one of the following:","messagePattern":"Start mode in XML must be one of the following:","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/WinSW.Core/Configuration/XmlServiceConfig.cs","lineNumber":416,"sourceCode":"                if (p is null)\n                {\n                    return base.StartMode;\n                }\n\n                try\n                {\n                    return (ServiceStartMode)Enum.Parse(typeof(ServiceStartMode), p, true);\n                }\n                catch (ArgumentException e)\n                {\n                    var builder = new StringBuilder();\n                    builder.AppendLine(\"Start mode in XML must be one of the following:\");\n                    foreach (string sm in Enum.GetNames(typeof(ServiceStartMode)))\n                    {\n                        builder.AppendLine(sm);\n                    }\n\n                    throw new InvalidDataException(builder.ToString(), e);\n                }\n            }\n        }\n\n        /// <summary>\n        /// True if the service should be installed with the DelayedAutoStart flag.\n        /// This setting will be applyed only during the install command and only when the Automatic start mode is configured.\n        /// </summary>\n        public override bool DelayedAutoStart => this.SingleBoolElementOrDefault(\"delayedAutoStart\", base.DelayedAutoStart);\n\n        public override bool Preshutdown => this.SingleBoolElementOrDefault(\"preshutdown\", base.Preshutdown);\n\n        public TimeSpan? PreshutdownTimeout\n        {\n            get\n            {\n                string? value = this.SingleElementOrNull(\"preshutdownTimeout\");\n                return value is null ? default : ParseTimeSpan(value);","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/winsw/winsw/blob/1d0ee4a91bad596d5e7e9c360f2b39ef54674674/src/WinSW.Core/Configuration/XmlServiceConfig.cs#L398-L434","documentation":"The <startmode> value is parsed into the ServiceStartMode enum via the case-insensitive Enum.Parse. An ArgumentException (value not matching any enum name) is caught and rethrown as InvalidDataException whose message lists the valid enum names. So the set of accepted values is whatever ServiceStartMode defines (typically Boot, System, Automatic, Manual, Disabled).","triggerScenarios":"<startmode>something</startmode> where \"something\" matches no ServiceStartMode name. Case does not matter, but the spelling must equal an enum name.","commonSituations":"Used \"Auto\" instead of \"Automatic\"; used a description like \"Delayed\"; typo; expected a value the enum doesn't define.","solutions":["Read the valid names from the exception message and use one of them.","Common valid values: Automatic, Manual, Disabled (and System/Boot).","For delayed auto-start use <delayedAutoStart> together with Automatic, not a separate start mode."],"exampleFix":"<!-- before -->\n<startmode>Auto</startmode>\n<!-- after -->\n<startmode>Automatic</startmode>","handlingStrategy":"validation","validationCode":"var v = dom.DocumentElement!.SelectSingleNode(\"startmode\")?.InnerText;\nif (v is not null && !Enum.GetNames(typeof(ServiceStartMode)).Any(n => string.Equals(n, v, StringComparison.OrdinalIgnoreCase)))\n    throw new InvalidOperationException($\"Invalid startmode: {v}\");","typeGuard":null,"tryCatchPattern":"try { _ = config.StartMode; }\ncatch (InvalidDataException ex) { /* message lists valid start modes */ }","preventionTips":["The exception message lists valid names — read it.","Use Automatic/Manual/Disabled as typical values.","Pair delayed start with Automatic via <delayedAutoStart>."],"tags":["xml","configuration","winsw","service"],"backgroundTag":null,"analyzedSha":"1d0ee4a91bad596d5e7e9c360f2b39ef54674674","analyzedAt":"2026-08-13T15:26:09.332Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}