When I run visual studio I constantly receive several errors that sounds pretty similar and Visual Studio can not open the design page.
Are you using the latest version? We have fixed similar issues in April Features crash frequently - Hard Crashes of Visual Studio - #16 by korchev and haven’t seen them since. If you use the latest version please let us know when those issues appear - do they appear as soon as you open a file? Do they appear after doing anything specific in the file?
I update every time I'm notified of a new version so I believe this is the latest. Version 1.42.2
In that case please answer my other questions. We need to reproduce the error at our side (we haven't reproduced it since April). Pasting the stacktrace would also help.
Now this is funny. As I sent my observation and your answer to it, the problem disappeared like it never existed. If it appears again I will notice you. Thank you anyway and sorry for wasting your time.
Hi @Djordje,
It seems the problem is intermittent and triggers under some conditions which are not always met. We will continue investigating what could be causing it and post an update if any progress is made. You haven't wasted our time - this is a legitimate issue and we will do our best to rectify it once and for all.
I make it happened again!
This is the Stack Trace as you previously asked:
StreamJsonRpc.RemoteInvocationException: Razor source generator did not produce a host output for project 'ErpBox': warning CS8785: Generator 'RazorSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The hintName 'Components/Pages/GKGKP_razor.g.cs' of the added source file must be unique within a generator. (Parameter 'hintName')'.
System.ArgumentException: The hintName 'Components/Pages/GKGKP_razor.g.cs' of the added source file must be unique within a generator. (Parameter 'hintName')
at Microsoft.CodeAnalysis.AdditionalSourcesCollection.Add(String hintName, SourceText source)
at Microsoft.CodeAnalysis.SourceOutputNode`1.AppendOutputs(IncrementalExecutionContext context, CancellationToken cancellationToken)
at StreamJsonRpc.JsonRpc.d__1771.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.ValueTask1.get_Result()
at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection1.<TryInvokeAsync>d__181.MoveNext()
RPC server exception:
System.InvalidOperationException: Razor source generator did not produce a host output for project 'ErpBox': warning CS8785: Generator 'RazorSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The hintName 'Components/Pages/GKGKP_razor.g.cs' of the added source file must be unique within a generator. (Parameter 'hintName')'.
System.ArgumentException: The hintName 'Components/Pages/GKGKP_razor.g.cs' of the added source file must be unique within a generator. (Parameter 'hintName')
at Microsoft.CodeAnalysis.AdditionalSourcesCollection.Add(String hintName, SourceText source)
at Microsoft.CodeAnalysis.SourceOutputNode`1.AppendOutputs(IncrementalExecutionContext context, 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.Razor.SemanticTokens.AbstractRazorSemanticTokensInfoService.GetSemanticTokensAsync(DocumentContext documentContext, LinePositionSpan span, Guid correlationId, Boolean colorBackground, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Razor.SemanticTokens.AbstractRazorSemanticTokensInfoService.GetSemanticTokensAsync(DocumentContext documentContext, LinePositionSpan span, Boolean colorBackground, Guid correlationId, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.Razor.RemoteSemanticTokensService.GetSemanticTokensDataAsync(RemoteDocumentContext context, LinePositionSpan span, Guid correlationId, 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, Func2 implementation, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func2 implementation, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Remote.RemoteWorkspaceManager.RunServiceAsync[T](ServiceBrokerClient client, Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
Thanks - the stack trace pinpoints it. This is a Visual Studio Razor source-generator bug (hintName ... must be unique within a generator): System.ArgumentException: The hintName of the added source file must be unique within a generator. (Parameter 'hintName') · Issue #84188 · dotnet/roslyn · GitHub. To recover, unload and reload the project (or restart VS).
To check whether our extension makes it worse: next time it happens, disable "Radzen Blazor for Visual Studio" (Extensions -> Manage Extensions), restart VS, and let us know if the errors still appear.
meanwhile ww continue investigating. so far we have managed to reproduce it only once of a hundred automated tests. probably it is somehow related to your app. Can you snd us the source of the page where the error shows up?
Yesterday I've disabled RB4VS and when I restart Visual Studio my .razor pages produces an error:
An error occurred in 'Miscellaneous Files' while attempting to open 'GKGKP.razor'
System.ArgumentException: Failed to get the editor factory manager for bfc57766-c230-4abc-997d-7b6d4ab6a037.
at Microsoft.VisualStudio.PlatformUI.Packages.ShellService.EditorFactories.EditorFactoryRegistrar.<GetMatchingEditorFactoryAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.<>c__DisplayClass86_0.<<CreateEditorInstanceAsync>g__GetEditorFactoryAsync|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.<CreateEditorInstanceAsync>d__86.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.<LoadDocumentFrameInternalAsync>d__85.MoveNext()
I've spent the whole day restoring the functionality of my VS. I reset the whole IDE and finally I repaired VS to make it work. Today after restoring my configuration (I need to enter several keys for various accounts) I noticed that RB4VS is not disabled and it still does not work well. Although my VS is running correctly so I disabled RB4VS again. Result: Same errors as yesterday, VS is out of function for .razor pages. Now with late experience I just enabled this not working RB4VS and visual studio is running ok.
Failed to get the editor factory manager for bfc57766-c230-4abc-997d-7b6d4ab6a037.
This error is expected and happens when VS loads a razor file that has already been opened with RB4VS. After disabling the RB4VS extension the editor is no longer found and the opened file fails to display. Simply closing the tab and reopening the .razor file resolves the error - VS uses the default .razor editor. Another way to open the default editor for a razor file is by right-clicking the file in solution explorer and picking "Open with" then choose the HTML editor.
We have just released a new version which should hopefully help the Razor source-generator bug from triggering too often.
Your previous update solved the problem that I have so thank you.
Now I have a similar problem with a phantom line in a code. When I want to edit .razor file in RBS4VS or RBS I receive an error:
E:\projekti\RiskAss2\Program.cs(136,29): error CS8801: Cannot use local variable or local function 'licenses' declared in a top-level statement in this context.
but this line does not have any code, it is just an empty line in a code. I believe that this error belongs to the same origin as previous.
Unfortunately the Program.cs file that you have sent us doesn't mention a variable named "licenses". You can probably use preprocessor to surround the code in Program.cs that uses it so Radzen Blazor Studio doesn't "see" it.
Yes, this is a completely different application so there is a new program.cs. If you need it I will send it to you.
Yes, you can send it to us as we are not yet sure what is causing it. Meanwhile as an immediate fix you can try my suggestion from the linked article:
#if !RADZEN
// code in Program.cs that contains "licenses"
#endif
