Register Log in

Sudden RenderTree error

Posted 9 days ago by heddle
-1

Hi,

After upgrading to Visual Studio Community preview 16.8.0 2.1 I suddenly go errors in a component's corresponding generated .g.cs files. For example, on the line below set a readonly attribute:

__builder.AddMarkupContent(1, "<h3>JSON representation of the model</h3>\r\n");
            __builder.OpenElement(2, "textarea");
            __builder.AddAttribute(3, "id", "jsonrep");
            __builder.AddAttribute(4, "readonly");
    //LINE GENERATING ERROR
            __builder.AddContent(5, 

 

The error message in visual studio is:

1>C:\Users\heddl\slamr-network-visualization\NetMapPrototype\obj\Debug\netstandard2.0\Razor\Pages\JsonPage.razor.g.cs(87,39,87,49): error CS1503: Argument 2: cannot convert from 'string' to 'in Microsoft.AspNetCore.Components.RenderTree.RenderTreeFrame'

Any help is greatly appreciated.

 

 

  • 1

    Do you have any empty attributes in your HTML tags? Like disabled instead of disabled="disabled"? Or maybe more likely, something like class="". If so, try adding a space in there, so it's class=" ". It looks like there is an issue with Preview 16.8.0 2.1 where empty attributes are causing issues. https://github.com/dotnet/aspnetcore/issues/25525

    Posted 8 days ago by selliott
    Edited 8 days ago
  • -1

    Thank you, that sounds promising. I will try it today, and report back.

    Posted 8 days ago by heddle
  • 1

    That was it! So even though the W3 examples show the readonly attribute without a value, and that's what I used in the .razor file, I had to give readonly a value. 

    I used the one suggested by the context editor: readonly="readonly". Seems a bit silly. Anyway, thanks again.  

    Posted 8 days ago by heddle
  • 0

    Good to hear it helped! I imagine the Visual Studio team will address the issue in a future release.

    Posted 8 days ago by selliott

Post a Reply

You must be logged in to add a new post.
An error has occurred. This application may no longer respond until reloaded. Reload 🗙