{"record":{"id":"1972b0a57e72f94a","repo":"dotnet/aspnetcore","slug":"the-property-parametername-on-component-type","errorCode":null,"errorMessage":"The property '{parameterName}' on component type '{targetType.FullName}' cannot be set explicitly because it only accepts cascading values.","messagePattern":"The property '(.+?)' on component type '(.+?)' cannot be set explicitly because it only accepts cascading values\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Reflection/ComponentProperties.cs","lineNumber":224,"sourceCode":"            else\n            {\n                // This should not happen\n                throw new InvalidOperationException(\n                    $\"No writer was cached for the property '{propertyInfo.Name}' on type '{targetType.FullName}'.\");\n            }\n        }\n        else\n        {\n            throw new InvalidOperationException(\n                $\"Object of type '{targetType.FullName}' does not have a property \" +\n                $\"matching the name '{parameterName}'.\");\n        }\n    }\n\n    [DoesNotReturn]\n    private static void ThrowForSettingCascadingParameterWithNonCascadingValue(Type targetType, string parameterName)\n    {\n        throw new InvalidOperationException(\n            $\"The property '{parameterName}' on component type '{targetType.FullName}' cannot be set \" +\n            $\"explicitly because it only accepts cascading values.\");\n    }\n\n    [DoesNotReturn]\n    private static void ThrowForSettingParameterWithCascadingValue(Type targetType, string parameterName)\n    {\n        throw new InvalidOperationException(\n            $\"The property '{parameterName}' on component type '{targetType.FullName}' cannot be set \" +\n            $\"using a cascading value.\");\n    }\n\n    [DoesNotReturn]\n    private static void ThrowForCaptureUnmatchedValuesConflict(Type targetType, string parameterName, Dictionary<string, object> unmatched)\n    {\n        throw new InvalidOperationException(\n            $\"The property '{parameterName}' on component type '{targetType.FullName}' cannot be set explicitly \" +\n            $\"when also used to capture unmatched values. Unmatched values:\" + Environment.NewLine +","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Reflection/ComponentProperties.cs#L206-L242","documentation":"ThrowForSettingCascadingParameterWithNonCascadingValue fires when the framework is asked to set a property directly (as a normal parameter) but the property is annotated only with [CascadingParameter] (a CascadingParameterAttributeBase) and does not also accept direct parameters. Cascading parameters receive their values from a CascadingValue provider in the render tree, not from explicit attribute assignment, so direct assignment is rejected.","triggerScenarios":"In markup, writing <MyComponent Theme=\"dark\" /> where Theme is declared as [CascadingParameter]. Programmatically calling SetDirectAsync or RenderTreeBuilder.AddAttribute with a value for a cascading-only parameter. Mixing up which properties are direct parameters versus cascading parameters.","commonSituations":"Confusing [Parameter] and [CascadingParameter] semantics; attempting to pass a value directly to what should be supplied by <CascadingValue>. Refactoring a parameter to cascading without removing direct usages. Authoring a component that expects a cascade but a consumer supplies it explicitly.","solutions":["Supply the value via <CascadingValue Name=\"Theme\" Value=\"dark\"><MyComponent /></CascadingValue> instead of as a direct attribute.","If direct assignment is desired, change the property from [CascadingParameter] to [Parameter].","For [CascadingParameter] properties that should also accept direct values, verify whether SupplyParameterFromQuery or another dual-purpose attribute is intended."],"exampleFix":"// before\n<MyComponent Theme=\"dark\" /> // Theme is [CascadingParameter]\n\n// after\n<CascadingValue Name=\"Theme\" Value=\"dark\">\n  <MyComponent />\n</CascadingValue>","handlingStrategy":"validation","validationCode":"// Before passing a value, confirm the property accepts direct parameters.\nvar prop = typeof(MyComponent).GetProperty(\"Theme\");\nvar acceptsDirect = prop?.GetCustomAttribute<ParameterAttribute>() != null;\nvar isCascadingOnly = prop?.GetCustomAttributes()\n    .OfType<CascadingParameterAttributeBase>().Any() == true && !acceptsDirect;\nif (isCascadingOnly)\n    throw new InvalidOperationException(\"Use <CascadingValue> for Theme.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Distinguish [Parameter] (direct) from [CascadingParameter] (cascade) usage.","Supply cascading values through <CascadingValue>, not direct attributes.","Document on each property how it should receive its value."],"tags":["blazor","parameters","cascading-values","binding"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}