skip to Main Content

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>’

enter image description here


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:

  1. Transfer everything to the codebehind
  2. Remove the duplication of the namespace and the name of the component (in fact, I pulled the components from their folders)
  3. I was looking for ways to convert ElementReference or extract my component from it (I didn’t find anything like that)
  4. 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


  1. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search