{"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/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/DynamicComponent.cs#L61-L97","documentation":"DynamicComponent only accepts two direct parameters: 'Type' and 'Parameters'. Any other attribute is rejected with InvalidOperationException. To pass values to the rendered component, use the Parameters dictionary rather than top-level attributes.","triggerScenarios":"<DynamicComponent Type=\"@t\" SomeProp=\"x\" /> instead of routing SomeProp through the Parameters dictionary.","commonSituations":"Confusing DynamicComponent with a regular component, copy-pasting attributes from a typed usage, or assuming DynamicComponent forwards arbitrary attributes.","solutions":["Move extra attributes into the Parameters dictionary.","Build a Dictionary<string, object?> with the inner component's parameters.","Keep only Type and Parameters as direct attributes on DynamicComponent."],"exampleFix":"// before\n<DynamicComponent Type=\"@compType\" Count=\"@n\" Label=\"@lbl\" />\n// after\n<DynamicComponent Type=\"@compType\" Parameters=\"@(new Dictionary<string,object?>{ [\"Count\"]=n, [\"Label\"]=lbl })\" />","handlingStrategy":"validation","validationCode":"// Only pass Type and Parameters directly; route everything else through Parameters.\nvar dynParams = new Dictionary<string, object?> { [\"Count\"] = n };\n<DynamicComponent Type=\"@t\" Parameters=\"@dynParams\" />","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember DynamicComponent accepts only Type and Parameters as direct attributes.","Build a Parameters dictionary for any inner-component values.","Code-review DynamicComponent usages for stray top-level attributes."],"tags":["blazor","dynamic-component","parameters","razor"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}