{"record":{"id":"a5f4e5a55533fa09","repo":"jstedfast/MailKit","slug":"capabilities-cannot-be-enabled-they-may-only-be-disabled-a5f4e5","errorCode":null,"errorMessage":"Capabilities cannot be enabled, they may only be disabled.","messagePattern":"Capabilities cannot be enabled, they may only be disabled\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Pop3/Pop3Client.cs","lineNumber":161,"sourceCode":"\t\t/// <summary>\n\t\t/// Gets the capabilities supported by the POP3 server.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// The capabilities will not be known until a successful connection has been made \n\t\t/// and may change once the client is authenticated.\n\t\t/// </remarks>\n\t\t/// <example>\n\t\t/// <code language=\"c#\" source=\"Examples\\Pop3Examples.cs\" region=\"Capabilities\"/>\n\t\t/// </example>\n\t\t/// <value>The capabilities.</value>\n\t\t/// <exception cref=\"System.ArgumentException\">\n\t\t/// Capabilities cannot be enabled, they may only be disabled.\n\t\t/// </exception>\n\t\tpublic Pop3Capabilities Capabilities {\n\t\t\tget { return engine.Capabilities; }\n\t\t\tset {\n\t\t\t\tif ((engine.Capabilities | value) > engine.Capabilities)\n\t\t\t\t\tthrow new ArgumentException (\"Capabilities cannot be enabled, they may only be disabled.\", nameof (value));\n\n\t\t\t\tengine.Capabilities = value;\n\t\t\t}\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Gets the expiration policy.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// <para>If the server supports the EXPIRE capability (<see cref=\"Pop3Capabilities.Expire\"/>), the value\n\t\t/// of the <see cref=\"ExpirePolicy\"/> property will reflect the value advertized by the server.</para>\n\t\t/// <para>A value of <c>-1</c> indicates that messages will never expire.</para>\n\t\t/// <para>A value of <c>0</c> indicates that messages that have been retrieved during the current session\n\t\t/// will be purged immediately after the connection is closed via the <c>QUIT</c> command.</para>\n\t\t/// <para>Values larger than <c>0</c> indicate the minimum number of days that the server will retain\n\t\t/// messages which have been retrieved.</para>\n\t\t/// </remarks>\n\t\t/// <example>","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Pop3/Pop3Client.cs#L143-L179","documentation":"Pop3Client.Capabilities setter only allows disabling capabilities that the engine currently reports: if the new value would add capability bits beyond the current engine capabilities, an ArgumentException is thrown. The property exists to force-disable features (like pipelining or top) for compatibility, never to enable ones the server didn't advertise.","triggerScenarios":"Assigning client.Capabilities = Pop3Capabilities pipelined values that include bits not already present, e.g. setting Pop3Capabilities.Pipelining when the server never advertised it, or OR-ing in extra flags.","commonSituations":"Trying to 'force-enable' a feature the server doesn't support to work around a capability detection problem; copying Capabilities flags from another client instance onto a fresh connection.","solutions":["Only assign a subset: value &= existing client.Capabilities before setting, or set individual flags you want disabled.","If the server genuinely supports a feature MailKit didn't detect, fix capability detection (e.g. the server's CAPA response) rather than forcing the flag.","To disable, mask off the unwanted bit: client.Capabilities &= ~Pop3Capabilities.Pipelining;"],"exampleFix":"// before\nclient.Capabilities = Pop3Capabilities.Pipelining | Pop3Capabilities.Top;\n\n// after\n// only disable, never enable:\nclient.Capabilities &= ~Pop3Capabilities.Pipelining;","handlingStrategy":"validation","validationCode":"var requested = Pop3Capabilities.Pipelining;\nif ((requested & ~client.Capabilities) != 0)\n    throw new InvalidOperationException(\"can only disable capabilities the server advertised\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only ever mask bits OFF: client.Capabilities &= ~Pop3Capabilities.X","Never try to enable a capability the server did not advertise via CAPA","If a feature is needed but undetected, fix the server's CAPA response or open a MailKit issue"],"tags":["pop3","capabilities","argument-validation","mailkit"],"backgroundTag":"invalid-argument-value","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}