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
18.83k stars 4k forks source link

Feature 'Edit and Continue' currently unavailable due to an internal error. Read out of bounds. #65176

Open vsfeedback opened 1 year ago

vsfeedback commented 1 year ago

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version] Each time I am trying to debug unit test from Test Explorer I am getting "Feature 'Edit and Continue' is currently unavailable due to an internal error." I had following version of Visual Studio 2022:17.3.6(when error started I had 17.3.3)

To reporuduce:

  1. Start project with unit tests.
  2. Open Tests Explorer
  3. Right click any test and select "Debug" 4.. Observe the issue. Break point in test would not be hit.

Things I tried to remedy the situation, but failed to resolve the issue:

  1. Installed VS 2022 version 17.3.6
  2. Tried to repair visual studio

System info: Microsoft Visual Studio Enterprise 2022 Version 17.3.6 VisualStudio.17.Release/17.3.6+32929.385 Microsoft .NET Framework Version 4.8.04084

Here is stack trace:

StreamJsonRpc.RemoteInvocationException: Read out of bounds.
   at StreamJsonRpc.JsonRpc.d__143`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.EditAndContinue.RemoteEditAndContinueServiceProxy.<>c__DisplayClass5_0.<b__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.CodeAnalysis.Remote.BrokeredServiceConnection`1.d__20`1.MoveNext()
RPC server exception:
System.BadImageFormatException: Read out of bounds.
      at System.Reflection.Throw.OutOfBounds()
      at System.Reflection.Metadata.Ecma335.CustomDebugInformationTableReader..ctor(Int32 numberOfRows, Boolean declaredSorted, Int32 hasCustomDebugInformationRefSize, Int32 guidHeapRefSize, Int32 blobHeapRefSize, MemoryBlock containingBlock, Int32 containingBlockOffset)
      at System.Reflection.Metadata.MetadataReader.InitializeTableReaders(MemoryBlock metadataTablesMemoryBlock, HeapSizes heapSizes, Int32[] rowCounts, Int32[] externalRowCountsOpt)
      at System.Reflection.Metadata.MetadataReader..ctor(Byte* metadata, Int32 length, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder, Object memoryOwner)
      at System.Reflection.Metadata.MetadataReaderProvider.GetMetadataReader(MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
      at Microsoft.CodeAnalysis.Debugging.DebugInformationReaderProvider.Portable.CreateEditAndContinueMethodDebugInfoReader()
      at Microsoft.CodeAnalysis.EditAndContinue.CommittedSolution.<>c__DisplayClass15_0.<b__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.CodeAnalysis.EditAndContinue.CommittedSolution.d__15.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.EditAndContinue.EditAndContinueWorkspaceService.d__10.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.EditAndContinue.RemoteEditAndContinueService.<>c__DisplayClass6_0.<b__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.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass10_0`1.<g__TryFastGetSolutionAndRunAsync|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.CodeAnalysis.Remote.RemoteWorkspace.d__10`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.BrokeredServiceBase.d__11`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.BrokeredServiceBase.d__14`1.MoveNext()

Original Comments

Feedback Bot on 10/13/2022, 09:16 PM:

(private comment, text removed)


Original Solutions

Viachaslau Herasimau solved on 10/22/2022, 04:23 PM, 0 votes:

After the following everything went back to normal:

  1. Uninstalled Postsharp nuget from Tests project
  2. Removed from test project file following section:
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.11.0">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles;analyzers;buildtransitive</IncludeAssets>
</PackageReference>

Strange.

tmat commented 1 year ago

The call to CreateEditAndContinueMethodDebugInfoReader should guard against BadImageFormatException and report good error message.

tmat commented 1 year ago

Uninstalled Postsharp nuget from Tests project

It is very likely that after PostSharp applies its IL transformations the EnC data in the PDB are not valid anymore. In general, Edit and Continue is not supported in projects that use any kind of IL postprocessing.