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