Skip to content

Default new Razor Components project loads empty page, then get Failed to reconnect to the server. [Retry?] message. #8520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Eilon opened this issue Mar 14, 2019 · 3 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed

Comments

@Eilon
Copy link
Contributor

Eilon commented Mar 14, 2019

Describe the bug

Default new Razor Components project loads empty page, then eventually times out with Failed to reconnect to the server. [Retry?] message.

To Reproduce

Steps to reproduce the behavior:

  1. Dev16 Preview 4.1
  2. File/New Project/Razor Components
  3. F5
  4. Browser opens with empty page
  5. Then eventually get Failed to reconnect to the server. [Retry?] message:
    image
  6. Clicking Retry doesn't seem to do anything

Expected behavior

A page should show up

Additional context

dotnet --info:

C:\Users\elipton>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview4-010745
 Commit:    7b46750b5c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview4-010745\

Host (useful for support):
  Version: 3.0.0-preview4-27513-07
  Commit:  f9965e5a7e

.NET Core SDKs installed:
  2.1.504 [C:\Program Files\dotnet\sdk]
  2.1.600-preview-009472 [C:\Program Files\dotnet\sdk]
  2.1.600-preview-009497 [C:\Program Files\dotnet\sdk]
  2.1.600 [C:\Program Files\dotnet\sdk]
  2.2.200-preview-009748 [C:\Program Files\dotnet\sdk]
  2.2.200-preview-009804 [C:\Program Files\dotnet\sdk]
  2.2.200 [C:\Program Files\dotnet\sdk]
  3.0.100-preview4-010745 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  <trimmed>
  Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview4-19162-05 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview4-27513-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview4-27511-44 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

And here's what's relevant in the CSPROJ:

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.Server" Version="3.0.0-preview4-19162-05" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview4-19162-05" />
  </ItemGroup>
@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Mar 14, 2019
@Eilon
Copy link
Contributor Author

Eilon commented Mar 14, 2019

Saw this in the console log, don't know if relevant:

Microsoft.Hosting.Lifetime: Information: Application started. Press Ctrl+C to shut down.
Microsoft.Hosting.Lifetime: Information: Hosting environment: Development
Microsoft.Hosting.Lifetime: Information: Content root path: C:\Users\elipton\source\repos\WebApplication57\WebApplication57
Microsoft.AspNetCore.Hosting.Internal.GenericWebHostService: Information: Request starting HTTP/2.0 GET https://localhost:44339/  
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Route matched with {page = "/Index"}. Executing page /Index
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Executing an implicit handler method - ModelState is Valid
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Executed an implicit handler method, returned result Microsoft.AspNetCore.Mvc.RazorPages.PageResult.
Microsoft.AspNetCore.Components.Browser.Rendering.RemoteRenderer: Warning: Unhandled exception rendering component: Unable to set property 'AppAssembly' on object of type 'Microsoft.AspNetCore.Components.Routing.Router'. The error was: Unable to cast object of type 'System.String' to type 'System.Reflection.Assembly'.

System.InvalidOperationException: Unable to set property 'AppAssembly' on object of type 'Microsoft.AspNetCore.Components.Routing.Router'. The error was: Unable to cast object of type 'System.String' to type 'System.Reflection.Assembly'. ---> System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Reflection.Assembly'.
   at Microsoft.AspNetCore.Components.Reflection.MemberAssignment.PropertySetter`2.SetValue(Object target, Object value)
   at Microsoft.AspNetCore.Components.ParameterCollectionExtensions.SetParameterProperties(ParameterCollection& parameterCollection, Object target)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Components.ParameterCollectionExtensions.SetParameterProperties(ParameterCollection& parameterCollection, Object target)
   at Microsoft.AspNetCore.Components.Routing.Router.SetParametersAsync(ParameterCollection parameters)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterCollection parameters)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.ProcessRenderQueue()
   at Microsoft.AspNetCore.Components.Rendering.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.RenderHandle.Render(RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
   at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker: Information: Executed page /Index in 174.8417ms
Microsoft.AspNetCore.Hosting.Internal.GenericWebHostService: Information: Request finished in 337.5319ms 200 text/html; charset=utf-8

But if it's not relevant, there still definitely shouldn't be some exception there.

@rynowak
Copy link
Member

rynowak commented Mar 17, 2019

This is related to ref-assemblies. Ref assemblies don't include non-public members, and components currently recommend using non-public members for component properties.

  {
    "Kind": "Components.Component",
    "Name": "Microsoft.AspNetCore.Components.Routing.Router",
    "AssemblyName": "Microsoft.AspNetCore.Components",
    "Documentation": null,
    "TagOutputHint": null,
    "TagMatchingRules": [
      {
        "TagName": "Router",
        "ParentTag": null,
        "TagStructure": 0,
        "Attributes": [],
        "Diagnostics": []
      }
    ],
    "BoundAttributes": [], // There should be something here!
    "AllowedChildTags": [],
    "Diagnostics": [],
    "Metadata": {
      "Runtime.Name": "Components.IComponent",
      "Common.TypeName": "Microsoft.AspNetCore.Components.Routing.Router"
    }
  },

The parameters of the component are not being discovered, and the compiler behaves differently depending on the declared type of a parameter (tag helpers). Since the parameters aren't being found, all parameters are treated like string-likes. So <Router AppAssembly="typeof(Program).Assembly" /> passes a string, not an Assembly` object.

This means that recent builds are complete blocked from using any components we ship in the box.

@rynowak
Copy link
Member

rynowak commented Mar 17, 2019

@SteveSandersonMS - lets discuss this this week.

@rynowak rynowak self-assigned this Mar 17, 2019
@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Mar 21, 2019
@rynowak rynowak added the bug This issue describes a behavior which is not expected - a bug. label Mar 26, 2019
@rynowak rynowak added this to the 3.0.0-preview4 milestone Mar 26, 2019
rynowak added a commit that referenced this issue Mar 26, 2019
This resolves the issue blocking use of component parameters from our
ref assemblies. Making properties public with private get is our
recommended guidance for wanting documentation to work in the IDE, and
it will be required when you ship ref assemblies - since ref assemblies
only contain public members.
rynowak added a commit that referenced this issue Mar 26, 2019
This resolves the issue blocking use of component parameters from our
ref assemblies. Making properties public with private get is our
recommended guidance for wanting documentation to work in the IDE.

We also now need to manually generate the ref-assembly types for these
so they will show up for tooling with setters. I've logged an issue to
track whether we want to keep this long term, it seems like a suitable
workaround for now.
rynowak added a commit that referenced this issue Mar 26, 2019
This resolves the issue blocking use of component parameters from our
ref assemblies. Making properties public with private get is our
recommended guidance for wanting documentation to work in the IDE.

We also now need to manually generate the ref-assembly types for these
so they will show up for tooling with setters. I've logged an issue to
track whether we want to keep this long term, it seems like a suitable
workaround for now.
@rynowak rynowak added Done This issue has been fixed and removed investigate labels Mar 27, 2019
@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed
Projects
None yet
Development

No branches or pull requests

3 participants