Visual Studio 2022 中。由于内部错误,“编辑并继续”功能当前不可用。读取越界

Visual Studio 2022. Feature 'Edit and Continue' is currently unavailable due to an internal error. Read out of bounds

提问人:fatherOfWine 提问时间:10/13/2022 最后编辑:fatherOfWine 更新时间:10/23/2022 访问量:922

问:

突然间,我开始在调试单元测试时遇到上述问题。 这是一个情况:

  1. 打开项目并打开测试资源管理器。
  2. 选择任何测试并尝试调试它。
  3. 从工具栏下方的标题和测试中的断点获得的消息将不被接受。

我尝试过的事情无济于事:

  1. 更新 VS 版本。曾经:17.3.3 现在:17.3.6
  2. 修复 VS.

下面是堆栈跟踪:

StreamJsonRpc.RemoteInvocationException: Read out of bounds. at StreamJsonRpc.JsonRpc.d__1431.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.BrokeredServiceConnection1.d__201.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_01.<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__101.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__111.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()

.NET 单元测试 调试 visual-studio-2022 postsharp

评论

0赞 Hans Passant 10/14/2022
BadImageFormatException似乎非常重要,调试信息有问题,似乎没有其他人有这个问题。可能是文件损坏或反恶意软件。如果这是一个错误,则在“完整”或“可移植”之间切换“项目>属性”>“生成”选项卡>“高级>调试信息”可能会有所帮助。

答:

0赞 fatherOfWine 10/23/2022 #1

避免了危机。采取以下措施后,情况恢复正常:

  1. 从测试项目中卸载了 Postsharp nuget

  2. 从以下部分的测试项目文件中删除:

    <PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.11.0">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles;analyzers;buildtransitive</IncludeAssets>
    </PackageReference>
    

在这些操作之后,没有产生任何错误,并且测试中的断点按预期命中。奇怪。