{"record":{"id":"6ac5b23870a6c1db","repo":"abpframework/abp","slug":"options-must-be-derived-from-the-typeof-abpdynami","errorCode":null,"errorMessage":"Options must be derived from the {typeof(AbpDynamicOptionsManager<>).FullName}!","messagePattern":"Options must be derived from the (.+?)!","errorType":"exception","errorClass":"AbpException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Core/Microsoft/Extensions/Options/OptionsAbpDynamicOptionsManagerExtensions.cs","lineNumber":29,"sourceCode":"    {\n        return options.ToDynamicOptions().SetAsync();\n    }\n\n    public static Task SetAsync<T>(this IOptions<T> options, string name)\n        where T : class\n    {\n        return options.ToDynamicOptions().SetAsync(name);\n    }\n\n    private static AbpDynamicOptionsManager<T> ToDynamicOptions<T>(this IOptions<T> options)\n        where T : class\n    {\n        if (options is AbpDynamicOptionsManager<T> dynamicOptionsManager)\n        {\n            return dynamicOptionsManager;\n        }\n\n        throw new AbpException($\"Options must be derived from the {typeof(AbpDynamicOptionsManager<>).FullName}!\");\n    }\n}\n","sourceCodeStart":11,"sourceCodeEnd":32,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Microsoft/Extensions/Options/OptionsAbpDynamicOptionsManagerExtensions.cs#L11-L32","documentation":"Thrown by OptionsAbpDynamicOptionsManagerExtensions.ToDynamicOptions when SetAsync is called on an IOptions<T> instance that is not an AbpDynamicOptionsManager<T>. ABP's dynamic-configuration feature overrides the default OptionsManager so option values can be refreshed at runtime; calling SetAsync on a plain/externally-supplied IOptions has no dynamic backing store to update.","triggerScenarios":"Invoking options.SetAsync() / options.SetAsync(name) where options is a standard OptionsManager<T>, a wrapped IOptions<T> from a non-ABP source, or a test double — anything that is not AbpDynamicOptionsManager<T>.","commonSituations":"Unit tests injecting a plain IOptions<T> (e.g. Options.Create(value)) and then calling SetAsync; code that resolves IOptions<T> from a container not configured with ABP's dynamic options; using Microsoft.Extensions.Options directly without the ABP options module.","solutions":["Ensure the AbpOptions module / dynamic-configuration infrastructure is loaded so IOptions<T> resolves as AbpDynamicOptionsManager<T> at runtime.","In tests, do not call SetAsync on Options.Create; instead register dynamic options or skip the SetAsync call.","If you only need static options, read .Value instead of calling SetAsync.","Confirm AbpDynamicOptionsManager is the registered IOptions<T> implementation (check that AddAbp/your module wired IOptions via the ABP options services)."],"exampleFix":"// before — Options.Create is not dynamic\nvar opts = Options.Create(new MyOptions { X = 1 });\nawait opts.SetAsync(); // throws\n\n// after — register through ABP dynamic options, or just read the value\nvar value = opts.Value;\n// or configure dynamic options via Configure<T>/ ABP's SetConfigurationValue path","handlingStrategy":"type-guard","validationCode":"// Only call SetAsync when the resolved options are ABP's dynamic manager\nif (options is Volo.Abp.Options.AbpDynamicOptionsManager<T> dynamicOpts)\n    await dynamicOpts.SetAsync();\nelse\n    throw new InvalidOperationException(\"IOptions<T> is not the ABP dynamic manager; cannot SetAsync.\");","typeGuard":"static bool IsDynamic<T>(IOptions<T> options) where T : class =>\n    options is Volo.Abp.Options.AbpDynamicOptionsManager<T>;","tryCatchPattern":null,"preventionTips":["Ensure the ABP options/dynamic-configuration module is loaded so IOptions<T> resolves as AbpDynamicOptionsManager<T>.","In tests, avoid SetAsync on Options.Create; read .Value instead.","Type-check before calling SetAsync when the source of IOptions<T> is uncertain."],"tags":["options","dynamic-configuration","abp-core","startup"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}