{"record":{"id":"12a3be476a93ae64","repo":"dotnet/aspnetcore","slug":"nameof-dynamiccomponent-does-not-accept-a-param","errorCode":null,"errorMessage":"{nameof(DynamicComponent)} does not accept a parameter with the name '{entry.Name}'. To pass parameters to the dynamically-rendered component, use the '{nameof(Parameters)}' parameter.","messagePattern":"(.+?) does not accept a parameter with the name '(.+?)'\\. To pass parameters to the dynamically-rendered component, use the '(.+?)' parameter\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/DynamicComponent.cs","lineNumber":79,"sourceCode":"    /// <inheritdoc />\n    [UnconditionalSuppressMessage(\"Trimming\", \"IL2072\", Justification = \"We expect that types used with DynamicComponent will be defined in assemblies that don't get trimmed.\")]\n    public Task SetParametersAsync(ParameterView parameters)\n    {\n        // This manual parameter assignment logic will be marginally faster than calling\n        // ComponentProperties.SetProperties.\n        foreach (var entry in parameters)\n        {\n            if (entry.Name.Equals(nameof(Type), StringComparison.OrdinalIgnoreCase))\n            {\n                Type = (Type)entry.Value;\n            }\n            else if (entry.Name.Equals(nameof(Parameters), StringComparison.OrdinalIgnoreCase))\n            {\n                Parameters = (IDictionary<string, object>)entry.Value;\n            }\n            else\n            {\n                throw new InvalidOperationException(\n                    $\"{nameof(DynamicComponent)} does not accept a parameter with the name '{entry.Name}'. To pass parameters to the dynamically-rendered component, use the '{nameof(Parameters)}' parameter.\");\n            }\n        }\n\n        if (Type is null)\n        {\n            throw new InvalidOperationException($\"{nameof(DynamicComponent)} requires a non-null value for the parameter {nameof(Type)}.\");\n        }\n\n        _renderHandle.Render(_cachedRenderFragment);\n        return Task.CompletedTask;\n    }\n\n    void Render(RenderTreeBuilder builder)\n    {\n        builder.OpenComponent(0, Type);\n\n        if (Parameters != null)","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/DynamicComponent.cs#L61-L97","documentation":"Thrown by DynamicComponent.SetParametersAsync when it receives a parameter whose name is not 'Type' or 'Parameters'. DynamicComponent deliberately does not use CaptureUnmatchedValues, so arbitrary parameters are rejected — to pass values to the dynamically-rendered child component you must use the Parameters dictionary. The rejection is at DynamicComponent.cs:77-81.","triggerScenarios":"Writing <DynamicComponent SomeProp=\"x\"> instead of passing SomeProp via the Parameters dictionary; trying to set component parameters directly on DynamicComponent in markup.","commonSituations":"Assuming DynamicComponent forwards unmatched attributes to the child; copy-pasting a usage that worked with a concrete component but applying it to DynamicComponent.","solutions":["Pass child parameters via the Parameters dictionary: <DynamicComponent Type=\"@t\" Parameters=\"@params\" /> where params is a Dictionary<string,object>.","Remove any direct attributes that aren't Type or Parameters."],"exampleFix":"// before\n<DynamicComponent Type=\"@componentType\" Title=\"@title\" OnClick=\"@handler\" />\n\n// after\n<DynamicComponent Type=\"@componentType\" Parameters=\"@_params\" />\n@code {\n    private Dictionary<string, object> _params = new()\n    {\n        [\"Title\"] = title,\n        [\"OnClick\"] = EventCallback.Create(this, handler)\n    };\n}","handlingStrategy":"validation","validationCode":"var valid = new[] { \"Type\", \"Parameters\" };\nforeach (var p in parameters)\n    if (!valid.Contains(p.Name))\n        throw new InvalidOperationException($\"Use Parameters dictionary, not '{p.Name}'.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass child component values via the Parameters dictionary on DynamicComponent.","Never add direct attributes other than Type or Parameters."],"tags":["blazor","dynamic-component","parameter-binding"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}