Skip to content

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

Closed
@NTaylorMullen

Description

@NTaylorMullen

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

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedExternalThis is an issue in a component not contained in this repository. It is open for tracking purposes.area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions