{"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/Reflection/ComponentProperties.cs#L206-L242","documentation":"Thrown by ComponentProperties.ThrowForSettingCascadingParameterWithNonCascadingValue when a parameter is cascading-only ([CascadingParameter] and not also a direct-accepting attribute) but a direct (non-cascading) value is supplied in markup. Cascading parameters are not part of the component's public API and cannot be set explicitly.","triggerScenarios":"<Child MyCascadingParam=\"value\" /> where MyCascadingParam is decorated with [CascadingParameter] only.","commonSituations":"Trying to pass a cascading value directly for convenience/testing; misunderstanding the difference between regular and cascading parameters; refactoring a [Parameter] into a [CascadingParameter] without updating call sites.","solutions":["Provide the value through a <CascadingValue> wrapper instead of setting the property directly.","If the value must be settable directly, keep it as a [Parameter] rather than a [CascadingParameter].","Review the component's declared cascading parameters and supply them via the cascading-value pipeline only."],"exampleFix":"// before\n<Child CurrentUser=\"@user\" /> // CurrentUser is [CascadingParameter]\n\n// after\n<CascadingValue Value=\"@user\" TValue=\"User\">\n    <Child />\n</CascadingValue>","handlingStrategy":"validation","validationCode":"// Detect cascading-only parameters so callers know not to set them directly.\nstatic bool IsCascadingOnly(Type componentType, string name)\n{\n    var p = componentType.GetProperty(name,\n        BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase);\n    if (p is null) return false;\n    bool cascading = p.GetCustomAttributes().OfType<CascadingParameterAttributeBase>().Any();\n    bool parameter = p.GetCustomAttribute<ParameterAttribute>() is not null;\n    return cascading && !parameter;\n}","typeGuard":"static bool ShouldUseCascadingValue(Type componentType, string name)\n    => IsCascadingOnly(componentType, name);","tryCatchPattern":null,"preventionTips":["Supply cascading values via <CascadingValue>, never via direct markup attributes.","Keep a property as [Parameter] if it must be set directly.","When converting a [Parameter] to [CascadingParameter], update all call sites to use CascadingValue.","Document cascading parameters clearly so callers do not try to set them directly."],"tags":["blazor","cascading-parameter","parameters","rendering"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}