After updating Visual Studio to version 17.6.0, the following error occurred in my MAUI project:
Error CS0029 Cannot implicitly convert type ‘Microsoft.AspNetCore.Components.ElementReference’ to ‘<componentName>’
Here is my code:
@using UI.Components.Dialogs.InfoDialog
@using UI.Components.Dialogs.InputDialog
@using UI.Components.Dialogs.MessageDialog
@using UI.Components.Dialogs.SettingsDialog
@using UI.Components.Dialogs.ProcedureTypeSelectorDialog
@using UI.Services;
@inject DialogService dialogService
<InputDialog @ref="inputDialog" />
<InfoDialog @ref="infoDialog" />
<MessageDialog @ref="messageDialog" />
<SettingsDialog @ref="settingsDialog" />
<ProcedureTypeSelectorDialog @ref="procedureTypeSelectorDialog" />
@code {
InputDialog inputDialog { set => dialogService.RegisterDialog(value); }
InfoDialog infoDialog { set => dialogService.RegisterDialog(value); }
MessageDialog messageDialog { set => dialogService.RegisterDialog(value); }
SettingsDialog settingsDialog { set => dialogService.RegisterDialog(value); }
ProcedureTypeSelectorDialog procedureTypeSelectorDialog { set => dialogService.RegisterDialog(value); }
}
I have tried the following:
- Transfer everything to the codebehind
- Remove the duplication of the namespace and the name of the component (in fact, I pulled the components from their folders)
- I was looking for ways to convert
ElementReference
or extract my component from it (I didn’t find anything like that) - Deleted folders .vs, bin, obj and rebuilt the project
Before updating Visual Studio (I was working on version 17.5), this code worked fine. After the update, when trying to run with the same code, I encountered this error. Thank you all in advance for your help!
2
Answers
This might be an issue on the new version of Visual Studio 17.6.0. I recommend you to report it as a new issue on the GitHub and report a problem with the Visual Studio product for more information.
Its reported on dotnet/AspNetCore.Docs
https://github.com/dotnet/AspNetCore.Docs/issues/17416