question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating new Blazor Client Side app -> Open .razor file can result in an exception

See original GitHub issue

Just found that after creating a Blazor client side application you can occasionally get:


Error encountered from project 'C:\Users\nimullen.REDMOND\source\repos\Repro\Repro\.\Repro.csproj': System.InvalidOperationException: The file 'C:/Users/nimullen.REDMOND/source/repos/Repro/Repro/Shared/MainLayout.razor' is not a descendent of the base path 'C:/Users/nimullen.REDMOND/source/repos/Repro/Repro/.'.   at Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectFileSystem.GetItem(String path, String fileKind)   at 
Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentState.GetImportsCore(DefaultProjectSnapshot project)   at 
Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultDocumentSnapshot.GetImports()   at 
Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentState.ComputedStateTracker.<GetImportsAsync>d__9.MoveNext() --- End of stack trace from previous location where exception was thrown ---    at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)   at 
Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentState.ComputedStateTracker.<GetGeneratedOutputAndVersionCoreAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown ---    at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultDocumentSnapshot.<GetGeneratedOutputAsync>d__20.MoveNext() --- End of stack trace from previous location where exception was thrown ---    at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at Microsoft.CodeAnalysis.Razor.BackgroundDocumentGenerator.<ProcessDocument>d__44.MoveNext() --- End of stack trace from previous location where exception was thrown ---    at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)   at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)   at Microsoft.CodeAnalysis.Razor.BackgroundDocumentGenerator.<TimerTick>d__48.MoveNext()
--



I’m having an extremely hard time reproducing the issue. That being said this is most likely a VS issue since IVsHierarchy is obviously providing us a bogus project path: https://github.com/aspnet/AspNetCore-Tooling/blob/master/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/DefaultTextBufferProjectService.cs#L67-L79

or the project system is providing us a bogus project path: https://github.com/aspnet/AspNetCore-Tooling/blob/ff1a749559a093b2f5bfce48da9597995f27c280/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/ProjectSystem/DefaultRazorProjectHost.cs#L107

@BillHiebert is there a known issue on the project system side of the world where UnconfiguredProject can have a funky project path when the project is in the midst of loading?

Here’s where I reprod it (ignore the null ref exception, that’s a WTE issue), you can see it mentioned in the activity logs: image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
phenningcommented, Jul 25, 2019

@NTaylorMullen Added you to the PR in the WebTools repo.

And yes, this will make 16.3-preview2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
ASP.NET Core Blazor dependency injection
Learn how Blazor apps can inject services into components. ... After creating a new app, examine part of the Program file:.
Read more >
Static files not working on Blazor apps using Razor Class ...
Static resources in the "wwwroot" folder of a Razor class library RCL, aren't deployed correctly. This is causing apps to crash due to...
Read more >
Blazor Best Practices: Handling Errors
Errors are likely to occur, the question is how to handle them. Let's take a look at best practices in handling them in...
Read more >
Unhandled Exceptions in Blazor Server with Error ...
Let's look at error boundaries in Blazor, a new feature that allows you to handle Blazor Server unhandled exceptions more easily.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found