Skip to content

dotnet watch crashes with 'Index was outside the bounds of the array' #49448

Open
@AndreiShenets

Description

@AndreiShenets

Describe the bug

I use 'dotnet watch' for .NET 9 Blazor project in Server Side Rendering mode. Very often when I change html on razor pages or components, it crashes with 'Index was outside the bounds of the array' exception. It happens not often but mostly when I do significant changes in my markup, move or add blocks of the code.

To Reproduce

There is no stable steps to reproduce

Exceptions (if any)

dotnet watch ❌ [Gea.Idp (net9.0)] Exited with error code -1
dotnet watch ❌ System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.EmitParametersFromOriginalMetadata(IMethodDefinition methodDef, MethodDefinitionHandle handle)
at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.CreateIndicesForMethod(IMethodDefinition methodDef, SymbolChange methodChange)
at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.CreateIndicesForNonTypeMembers(ITypeDefinition typeDef)
at Microsoft.Cci.MetadataWriter.g__createIndices|102_0(ITypeDefinition typeDef, Queue1 typesToIndex) at Microsoft.Cci.MetadataWriter.CreateIndicesForModule() at Microsoft.Cci.MetadataWriter.CreateIndices() at Microsoft.Cci.MetadataWriter.BuildMetadataAndIL(PdbWriter nativePdbWriterOpt, BlobBuilder ilBuilder, PooledBlobBuilder& mappedFieldDataBuilder, PooledBlobBuilder& managedResourceDataBuilder, Blob& mvidFixup, Blob& mvidStringFixup) at Microsoft.Cci.MetadataWriter.WriteMetadataAndIL(PdbWriter nativePdbWriterOpt, Stream metadataStream, Stream ilStream, Stream portablePdbStreamOpt, MetadataSizes& metadataSizes) at Microsoft.CodeAnalysis.Compilation.SerializeToDeltaStreams(CommonPEModuleBuilder moduleBeingBuilt, DefinitionMap definitionMap, SymbolChanges changes, Stream metadataStream, Stream ilStream, Stream pdbStream, ArrayBuilder1 updatedMethods, ArrayBuilder1 changedTypes, DiagnosticBag diagnostics, Func2 testSymWriterFactory, String pdbFilePath, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.Emit.EmitHelpers.EmitDifference(CSharpCompilation compilation, EmitBaseline baseline, IEnumerable1 edits, Func2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, CompilationTestData testData, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Compilation.EmitDifference(EmitBaseline baseline, IEnumerable1 edits, Func2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.EditAndContinue.EditSession.EmitSolutionUpdateAsync(Solution solution, ActiveStatementSpanProvider solutionActiveStatementSpanProvider, UpdateId updateId, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.EditAndContinue.DebuggingSession.EmitSolutionUpdateAsync(Solution solution, IImmutableSet1 runningProjects, ActiveStatementSpanProvider activeStatementSpanProvider, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.ExternalAccess.Watch.Api.WatchHotReloadService.GetUpdatesAsync(Solution solution, IImmutableSet1 runningProjects, CancellationToken cancellationToken)
at Microsoft.DotNet.Watch.CompilationHandler.HandleManagedCodeChangesAsync(Func`3 restartPrompt, CancellationToken cancellationToken)
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
at Microsoft.DotNet.Watch.Program.RunAsync()
dotnet watch ❌ An unexpected error occurred

Further technical details

.NET SDK:
Version: 9.0.301
Commit: a596cd2
Workload version: 9.0.300-manifests.07067f5b
MSBuild version: 17.14.5+edd3bbf37

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.301\

.NET workloads installed:
[aspire]
Installation Source: VS 17.14.36203.30
Manifest Version: 8.2.2/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
Install Type: Msi

Configured to use loose manifests when installing new manifests.

Host:
Version: 10.0.0-preview.5.25277.114
Architecture: x64
Commit: ddf39a1b46

.NET SDKs installed:
6.0.428 [C:\Program Files\dotnet\sdk]
8.0.411 [C:\Program Files\dotnet\sdk]
9.0.301 [C:\Program Files\dotnet\sdk]
10.0.100-preview.5.25277.114 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0-preview.5.25277.114 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0-preview.5.25277.114 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.0-preview.5.25277.114 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
P:\global.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions