dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.04k stars 4.03k forks source link

Exception from Visual Studio while coding #72074

Open ArchieCoder opened 8 months ago

ArchieCoder commented 8 months ago

Latest VS version. Exception happens while coding.

StreamJsonRpc.RemoteInvocationException: The solution does not contain the specified document.
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__151`1.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.ValueTask`1.get_Result()
   at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__22`1.MoveNext()
RPC server exception:
System.InvalidOperationException: The solution does not contain the specified document.
      at Microsoft.CodeAnalysis.Shared.Extensions.ISolutionExtensions.GetRequiredDocument(Solution solution, DocumentId documentId)
      at Microsoft.CodeAnalysis.Rename.ConflictEngine.ConflictResolver.Session.GetRenamedSymbolInCurrentSolutionAsync(MutableConflictResolution conflictResolution)
      at Microsoft.CodeAnalysis.Rename.ConflictEngine.ConflictResolver.Session.IdentifyConflictsAsync(HashSet`1 documentIdsForConflictResolution, IEnumerable`1 allDocumentIdsInProject, ProjectId projectId, MutableConflictResolution conflictResolution, ImmutableHashSet`1 conflictLocations)
      at Microsoft.CodeAnalysis.Rename.ConflictEngine.ConflictResolver.Session.ResolveConflictsAsync()
      at Microsoft.CodeAnalysis.Rename.ConflictEngine.ConflictResolver.ResolveSymbolicLocationConflictsInCurrentProcessAsync(SymbolicRenameLocations renameLocations, String replacementText, ImmutableArray`1 nonConflictSymbolKeys, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Rename.Renamer.RenameSymbolInCurrentProcessAsync(Solution solution, ISymbol symbol, String newName, SymbolRenameOptions options, CodeCleanupOptionsProvider cleanupOptions, ImmutableArray`1 nonConflictSymbolKeys, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Rename.Renamer.RenameSymbolAsync(Solution solution, ISymbol symbol, String newName, SymbolRenameOptions options, CodeCleanupOptionsProvider fallbackOptions, ImmutableArray`1 nonConflictSymbolKeys, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteRenamerService.<>c__DisplayClass4_0.<<RenameSymbolAsync>b__0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass9_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, Int32 workspaceVersion, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Int32 workspaceVersion, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunWithSolutionAsync[T](Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunServiceImplAsync[T](Func`2 implementation, CancellationToken cancellationToken)
CyrusNajmabadi commented 8 months ago

@jasonmalinowski something to do with generated files probably?

ArchieCoder commented 8 months ago

@CyrusNajmabadi @jasonmalinowski Here is my example just now. I'm not doing anything fancy. Duplicate a line and type new letters.

I get this experience 10-15 times a day for weeks.

image

CyrusNajmabadi commented 8 months ago

Please file the stacks you're running into. We're fixing the issues reported.

sharwell commented 8 months ago

I suspect this issue will be heavily mitigated in 17.10 Preview 1 by #68214

jasonmalinowski commented 8 months ago

@ArchieCoder If you can give 17.9.0 a shot, we just shipped it a few minutes ago. One possible cause of the stack you posted is fixed in it (but hard to say without trying it).

ArchieCoder commented 8 months ago

Installing! I will report back my new stack traces if any. Thanks for the fast update.

kubakorecek commented 8 months ago

I have same problem on 17.9 and 17.10 Preview. It is happenig always after I uupdate and add SDK

StreamJsonRpc.RemoteInvocationException: Can't create a reference to a module.
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__151`1.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.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__21.MoveNext()
RPC server exception:
System.NotSupportedException: Can't create a reference to a module.
      at Microsoft.CodeAnalysis.CompilationReference.GetProperties(Compilation compilation, ImmutableArray`1 aliases, Boolean embedInteropTypes)
      at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ToMetadataReference(ImmutableArray`1 aliases, Boolean embedInteropTypes)
      at Microsoft.CodeAnalysis.SolutionCompilationState.CompilationTracker.GetPartialMetadataReference(ProjectState fromProject, ProjectReference projectReference)
      at Microsoft.CodeAnalysis.SolutionCompilationState.CompilationTracker.GetPartialCompilationState(SolutionCompilationState compilationState, DocumentId id, ProjectState& inProgressProject, CompilationPair& compilations, CompilationTrackerGeneratorInfo& generatorInfo, Dictionary`2& metadataReferenceToProjectId, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.SolutionCompilationState.CompilationTracker.FreezePartialStateWithTree(SolutionCompilationState compilationState, DocumentState docState, SyntaxTree tree, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.SolutionCompilationState.WithFrozenPartialCompilationIncludingSpecificDocument(DocumentId documentId, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Document.WithFrozenPartialSemantics(CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DesignerAttribute.DesignerAttributeDiscoveryService.ProcessProjectAsync(Project project, Document specificDocument, Boolean useFrozenSnapshots, ICallback callback, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DesignerAttribute.DesignerAttributeDiscoveryService.ProcessSolutionAsync(Solution solution, DocumentId priorityDocumentId, Boolean useFrozenSnapshots, ICallback callback, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<>c__DisplayClass16_0.<<RunServiceAsync>b__1>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass9_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, Int32 workspaceVersion, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Int32 workspaceVersion, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunWithSolutionAsync[T](Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.<>c__DisplayClass16_0.<<RunServiceAsync>b__0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunServiceImplAsync(Func`2 implementation, CancellationToken cancellationToken)

17.9 after uupdate image

CyrusNajmabadi commented 8 months ago

@kubakorecek that seems entirely unrelated. Can you file a new issue with your repro project?

jasonmalinowski commented 8 months ago

I filed https://github.com/dotnet/roslyn/issues/72183 for @kubakorecek's issue since I think I recognize this one.

kubakorecek commented 8 months ago

@CyrusNajmabadi SUure, but i fix it by actually restarting whole computer. So basiccally it seems to have this problem only until first hard restart... so i guess i will leave it.