Blazor wasm: RZ9991 build error when updating from 7.0.203 to 7.0.302 sdk
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
When using a control WrappedSwitch that extends another control WrappedCheckbox which then extends InputBase<bool> using the WrappedSwitch with @bind-Value="SomeBool" will compile ok in 7.0.203 but in 7.0.302 results in:
error RZ9991: The attribute names could not be inferred from bind attribute 'bind-Value'. Bind attributes should be of the form 'bind' or 'bind-value' along with their corresponding optional parameters like 'bind-value:event', 'bind:format' etc.
Expected Behavior
The code should compile in both sdk vesions
Steps To Reproduce
Create a new blazor wasm project from a template.
In the shared folder create the following controls:
WrappedCheckbox
@using System.Diagnostics.CodeAnalysis
@inherits InputBase<bool>
<div class="form-check @WrapperDivCSS">
<input id="@Id" class="form-check-input" type="checkbox" @bind="CurrentValue" @attributes="AdditionalAttributes" />
<label class="form-check-label" for="@Id">@Label</label>
</div>
@code {
[Parameter] public string? Label { get; set; }
[Parameter] public string? WrapperDivCSS { get; set; }
string Id { get; init; } = Guid.NewGuid().ToString();
protected override bool TryParseValueFromString(string? value, out bool result, [NotNullWhen(false)] out string? validationErrorMessage)
{
bool parsed = bool.TryParse(value, out result);
validationErrorMessage = parsed ? null : $"Failed to parse {value} as a boolean";
return parsed;
}
}
WrappedSwitch
@inherits WrappedCheckbox
<WrappedCheckbox Label="@Label" Value="@Value" ValueChanged="@ValueChanged" ValueExpression="@ValueExpression"
DisplayName="@DisplayName" WrapperDivCSS="form-switch" AdditionalAttributes="@AdditionalAttributes" />
@code {
}
Then replace the Index page with:
@page "/"
<PageTitle>Index</PageTitle>
<EditForm Model="EditItem">
<WrappedSwitch Label="My Switch" @bind-Value="EditItem.MyProp"/>
</EditForm>
@code {
public class EditModel
{
public bool MyProp { get; set; }
}
public EditModel EditItem { get; set; } = new();
}
Compile using both sdks and 203 will succeed while 302 fails
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
Issue Analytics
- State:
- Created 4 months ago
- Reactions:6
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Blazor WebAssembly .NET6 upgrade to .NET7 causes JS ...
A minimal reproducible example showing the code that reproduces the error would be ideal. – dbc. Nov 21, 2022 at 15:40.
Read more >Publish Blazor WebAssembly With VS2022 Ver 17.2.5 Error
In this version, if you publish the blazor webassembly project, you got error: C:\Program Files\dotnet\sdk\6.0.301\Sdks\Microsoft.NET.Sdk.
Read more >ASP.NET Core Blazor forms and input components
The Blazor framework supports forms and provides built-in input components: ... API's response to make it only return the validation errors, ...
Read more >ASP.NET Core Blazor data binding
When an <input> element loses focus, its bound field or property is updated. Bind.razor : razor. Copy.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I found a way around it, by reading some of the other issues that have been posted about this.
I simply had to derive the “most” base component in the hierarchy chain from
ComponentBaseexplicitly (in a the .razor.cs file), and this fixed the errors for us.I have the same issue (a component that’s derived from a base component and the property to
@bindto is in the base component).This is blocking for us. I have to pin the sdk version to 7.0.203 to be able to build.
It’s very strange behavior to say the least… the compiler is complaining, but the error is not visible in the code (with the red squiggle) like it normally is.
When I use
@bind-Value(where the Value and ValueChanged properties are defined in the base class) like this;I get:
And when I remove the
@bind-Value:I get another error:
I have tried adding a @using statement, or fully qualifying the namespace, but nothing helps.