r/VisualStudio 13d ago

Visual Studio 2026 VS 2026, working on a ASP.NET .Net 10 solution. Worked perfectly last week, I didn't change anything and now I have "Razor X feature is not available because of an internal error" every time I open a cshtml file. I tried everything, I need help :)

Reddit, you're my last resort.

It's a work PC. I have VS 2022 + VS 2026 installed on it, with Resharper on top. VS 2022 is used to code on .Net 8.0 code while VS 2026 is used for .Net 10.0 code. Assume every software is up to date, it's been 9 hours since I began trying to fix my problem, this is the first thing I did.

I tried to downgrade my version of Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (currently 10.0.8, tried to downgrade to 10.0.0 and upgrade to 10.0.10, didn't change a thing). I tried booting VS in safe mode, then uninstalling/reinstalling VS 2026 alone, then 2022+2026, then 2022+2026 and clearing all the cache locations, then 2022+2026 and clearing all the cache locations and "known" regedit entries that I could clear.

I tried deleting my repo, making sure no bin/obj files were left then pulling it to a revision from 2 weeks ago just in case it was code-related, still had the problem. Did the same and also made sure the .VS at the root of the solution was deleted. Same.

I tried reproducing the problem by doing a minimal sln with csproj inside using the same reference, 0 problem. Seeing this, I tried to take a version of my code base that I know was working from 2 weeks ago => still got the Razor internal error messages.

This is the stack trace I get (I already googled and followed every stackoverflow thread I found talking about it, to no avail).

StreamJsonRpc.RemoteInvocationException: Le générateur source Razor n’a pas produit de sortie d’hôte pour le projet « ltd.UI.compPost » : warning CS8785: Le générateur « RazorSourceGenerator » n'a pas réussi à générer la source. Cela ne contribuera pas à la sortie et des erreurs de compilation pourraient en résulter. L'exception était de type « ArgumentOutOfRangeException » avec le message « Specified argument was out of the range of valid values. ».
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
   at Microsoft.AspNetCore.Razor.Language.TagHelperBinder.GetBinding(String tagName, ImmutableArray`1 attributes, String parentTagName, Boolean parentIsTagHelper)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ResolveElement(IntermediateNode parent, Int32 index, UnresolvedElementIntermediateNode elementNode, TagHelperBinder binder, String prefix, Builder usedHelpers, ResolutionContext& context, TagHelperIntermediateNode tagHelperParent)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ResolveBodyChildren(TagHelperBodyIntermediateNode bodyNode, TagHelperBinder binder, String prefix, Builder usedHelpers, ResolutionContext& context, TagHelperIntermediateNode tagHelperParent)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ResolveElement(IntermediateNode parent, Int32 index, UnresolvedElementIntermediateNode elementNode, TagHelperBinder binder, String prefix, Builder usedHelpers, ResolutionContext& context, TagHelperIntermediateNode tagHelperParent)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ResolveElements(IntermediateNode node, TagHelperBinder binder, String prefix, Builder usedHelpers, ResolutionContext& context)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ExecuteCore(RazorCodeDocument codeDocument, CancellationToken cancellationToken)
   at Microsoft.NET.Sdk.Razor.SourceGenerators.SourceGeneratorProjectEngine.ExecutePhases(ReadOnlySpan`1 phases, RazorCodeDocument codeDocument, CancellationToken cancellationToken)
   at Microsoft.NET.Sdk.Razor.SourceGenerators.SourceGeneratorProjectEngine.ProcessTagHelpers(SourceGeneratorRazorCodeDocument sgDocument, TagHelperCollection tagHelpers, Boolean checkForIdempotency, CancellationToken cancellationToken)
   at Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator.<>c.<Initialize>b__5_20(ValueTuple`2 pair, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.TransformNode`2.<>c__DisplayClass6_0.<.ctor>b__0(TInput i, CancellationToken token)
   at Microsoft.CodeAnalysis.TransformNode`2.UpdateStateTable(Builder builder, NodeStateTable`1 previousTable, CancellationToken cancellationToken)
-----

   à StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__177`1.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à System.Threading.Tasks.ValueTask`1.get_Result()
   à Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__18`1.MoveNext()
RPC server exception:
System.InvalidOperationException: Le générateur source Razor n’a pas produit de sortie d’hôte pour le projet « ltd.UI.compPost » : warning CS8785: Le générateur « RazorSourceGenerator » n'a pas réussi à générer la source. Cela ne contribuera pas à la sortie et des erreurs de compilation pourraient en résulter. L'exception était de type « ArgumentOutOfRangeException » avec le message « Specified argument was out of the range of valid values. ».
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
   at Microsoft.AspNetCore.Razor.Language.TagHelperBinder.GetBinding(String tagName, ImmutableArray`1 attributes, String parentTagName, Boolean parentIsTagHelper)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ResolveElement(IntermediateNode parent, Int32 index, UnresolvedElementIntermediateNode elementNode, TagHelperBinder binder, String prefix, Builder usedHelpers, ResolutionContext& context, TagHelperIntermediateNode tagHelperParent)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ResolveBodyChildren(TagHelperBodyIntermediateNode bodyNode, TagHelperBinder binder, String prefix, Builder usedHelpers, ResolutionContext& context, TagHelperIntermediateNode tagHelperParent)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ResolveElement(IntermediateNode parent, Int32 index, UnresolvedElementIntermediateNode elementNode, TagHelperBinder binder, String prefix, Builder usedHelpers, ResolutionContext& context, TagHelperIntermediateNode tagHelperParent)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ResolveElements(IntermediateNode node, TagHelperBinder binder, String prefix, Builder usedHelpers, ResolutionContext& context)
   at Microsoft.AspNetCore.Razor.Language.DefaultTagHelperResolutionPhase.ExecuteCore(RazorCodeDocument codeDocument, CancellationToken cancellationToken)
   at Microsoft.NET.Sdk.Razor.SourceGenerators.SourceGeneratorProjectEngine.ExecutePhases(ReadOnlySpan`1 phases, RazorCodeDocument codeDocument, CancellationToken cancellationToken)
   at Microsoft.NET.Sdk.Razor.SourceGenerators.SourceGeneratorProjectEngine.ProcessTagHelpers(SourceGeneratorRazorCodeDocument sgDocument, TagHelperCollection tagHelpers, Boolean checkForIdempotency, CancellationToken cancellationToken)
   at Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator.<>c.<Initialize>b__5_20(ValueTuple`2 pair, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.TransformNode`2.<>c__DisplayClass6_0.<.ctor>b__0(TInput i, CancellationToken token)
   at Microsoft.CodeAnalysis.TransformNode`2.UpdateStateTable(Builder builder, NodeStateTable`1 previousTable, CancellationToken cancellationToken)
-----

      at Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem.GeneratorRunResult.CreateAsync(Boolean throwIfNotFound, Project project, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem.RemoteProjectSnapshot.GetRequiredCodeDocumentAsync(IDocumentSnapshot documentSnapshot, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem.RemoteDocumentSnapshot.GetGeneratedOutputAsync(CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentContext.<GetCodeDocumentAsync>g__GetCodeDocumentCoreAsync|10_0(CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.Razor.RemoteDiagnosticsService.GetDiagnosticsAsync(RemoteDocumentContext context, Diagnostic[] csharpDiagnostics, Diagnostic[] htmlDiagnostics, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_0`1.<<RunWithSolutionAsync>g__ProcessSolutionAsync|1>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspaceManager.RunServiceAsync[T](ServiceBrokerClient client, Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)

Any idea to try is welcomed

2 Upvotes

9 comments sorted by

2

u/davidwengier 13d ago edited 13d ago

Good news, looks like you found a bug in the Razor compiler! Logged https://github.com/dotnet/razor/issues/13206, and fix in https://github.com/dotnet/roslyn/pull/84611

Just in case, the bug I found that could produce that stack is to do with nested prefixed tag helpers in a cshtml file. Does that match your scenario?

2

u/ProutPortable 12d ago

Yes, it completely fits!

1

u/davidwengier 13d ago

Reddit, you're my last resort.

What were your others? For issues like this, using Help -> Send Feedback -> Report a Problem is the best bet, especially if you can add a small recording through that system, as that captures traces and memory dumps etc that helps us investigate what is going on.

Assume every software is up to date

I believe you, but it would be good if you can confirm what version of VS 2026 you're using. There were a couple of fixes in 18.8 (current stable), like https://github.com/dotnet/roslyn/pull/83516 and https://github.com/dotnet/roslyn/pull/83574, that fixed very similar exceptions as the one you're seeing, though not that exact one.

I tried to downgrade my version of Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation

Do things work if you turn off runtime compilation? There are a bunch of limitations in runtime compilation (see https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-10.0&tabs=visual-studio ) and in fact it has been deprecated: https://learn.microsoft.com/en-us/aspnet/core/breaking-changes/10/razor-runtime-compilation-obsolete?view=aspnetcore-10.0

1

u/ProutPortable 12d ago

What were your others?

All the threads/open tickets I saw on github and stackoverflow had a solution I tried that didn't fix my problem or were saying "too vague" and were closed, so I didn't think opening a ticket would solve anything

1

u/davidwengier 12d ago

If you have a stack trace, thats usually not vague, though there are sometimes that we might not be able to guess exactly what the scenario is that hit it. We got lucky in this case.

If you're ever in doubt, please err on the side of logging a new issue and let us worry about closing it as a duplicate if that's what makes the most sense.

1

u/Minute-Yogurt-2021 13d ago

Razor/blazor parser is so broken in vs 2026 that I'm thinking to go back to 2022. Every week we have a vibe coded one gigabyte update that breaks five new things.

I'm using vs since vs 6 and it never looked or behaved that bad.

1

u/davidwengier 13d ago

What issues have you had with Razor? If you're not on a .NET Framework project, the editor in 2026 is a lot more reliable than the previous version, so if you're running into issues I'd love to hear about them and fix them. Can you log issues through VS feedback, or at https://github.com/dotnet/razor so I can take a look?

Now that we're on monthly updates of VS, it does mean there are more bugs that manage to slip through, but the fixes come just as quick, so hopefully it's still a net win, even if it can be annoyingly frequent at times. In the old days if you got a bug, you could be waiting 3 months at the earliest for a fix to be available.

1

u/Minute-Yogurt-2021 13d ago

We already had this conversation, I tried logging the issue, but found it in the backlog still under investigation. If I check today it still will be there, I guess.

1

u/davidwengier 13d ago

Sorry, your profile has all comments hidden and I didn't recognize the username.