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.12k stars 4.04k forks source link

Edit and Continue with Visual Studio 2017 (Version 15.7.1) and IIS Express (x64) fails. (Null-Reference-Exception in CSharpSymbolMatcher.MatchSymbols.VisitNamespace) #26840

Open Markus1980Wien opened 6 years ago

Markus1980Wien commented 6 years ago

Hi I am using Visual Studion 2017 Version 15.7.1 on a Windows 10 and IIS Express (x64):

Everytime I modify code while debugging, I cannot continue.:

I have to stop and start again to apply the changes.

I get the following Error.

Severity Code Description Project File Line Suppression State Error ENC0003 Can't apply changes -- unexpected error: 'System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamespace(NamespaceSymbol namespace) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamespace(NamespaceSymbol namespace) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamespace(NamespaceSymbol namespace) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamespace(NamespaceSymbol namespace) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamedType(NamedTypeSymbol sourceType) at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MapReference(ITypeReference reference) at Microsoft.CodeAnalysis.Emit.EncVariableSlotAllocator.GetPreviousLocal(ITypeReference currentType, ILocalSymbolInternal currentLocalSymbol, String nameOpt, SynthesizedLocalKind kind, LocalDebugId id, LocalVariableAttributes pdbAttributes, LocalSlotConstraints constraints, ImmutableArray1 dynamicTransformFlags, ImmutableArray1 tupleElementNames) at Microsoft.CodeAnalysis.CodeGen.LocalSlotManager.DeclareLocalImpl(ITypeReference type, ILocalSymbolInternal symbolOpt, String nameOpt, SynthesizedLocalKind kind, LocalDebugId id, LocalVariableAttributes pdbAttributes, LocalSlotConstraints constraints, ImmutableArray1 dynamicTransformFlags, ImmutableArray1 tupleElementNames) at Microsoft.CodeAnalysis.CodeGen.LocalSlotManager.DeclareLocal(ITypeReference type, ILocalSymbolInternal symbol, String name, SynthesizedLocalKind kind, LocalDebugId id, LocalVariableAttributes pdbAttributes, LocalSlotConstraints constraints, ImmutableArray1 dynamicTransformFlags, ImmutableArray1 tupleElementNames, Boolean isSlotReusable) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.DefineLocal(LocalSymbol local, SyntaxNode syntaxNode) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(ImmutableArray1 statements) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementList(BoundStatementList list) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl() at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(PEModuleBuilder moduleBuilder, MethodSymbol method, Int32 methodOrdinal, BoundStatement block, ImmutableArray1 lambdaDebugInfo, ImmutableArray1 closureDebugInfo, StateMachineTypeSymbol stateMachineTypeOpt, VariableSlotAllocator variableSlotAllocatorOpt, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, ImportChain importChainOpt, Boolean emittingPdb, Boolean emitTestCoverageData, ImmutableArray1 dynamicAnalysisSpans) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamedType(NamedTypeSymbol symbol, TypeCompilationState arg) at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor2 visitor, TArgument argument) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamespace(NamespaceSymbol symbol, TypeCompilationState arg) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor2 visitor, TArgument argument) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamespace(NamespaceSymbol symbol, TypeCompilationState arg) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor2 visitor, TArgument argument) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamespace(NamespaceSymbol symbol, TypeCompilationState arg) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor2 visitor, TArgument argument) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethodBodies(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, Boolean emittingPdb, Boolean emitTestCoverageData, Boolean hasDeclarationErrors, DiagnosticBag diagnostics, Predicate1 filterOpt, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileMethods(CommonPEModuleBuilder moduleBuilder, Boolean emittingPdb, Boolean emitMetadataOnly, Boolean emitTestCoverageData, DiagnosticBag diagnostics, Predicate1 filterOpt, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Compilation.Compile(CommonPEModuleBuilder moduleBuilder, Boolean emittingPdb, DiagnosticBag diagnostics, Predicate1 filterOpt, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.CSharp.Emit.EmitHelpers.EmitDifference(CSharpCompilation compilation, EmitBaseline baseline, IEnumerable1 edits, Func2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, ICollection1 updatedMethods, CompilationTestData testData, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.EmitDifference(EmitBaseline baseline, IEnumerable1 edits, Func2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, ICollection1 updatedMethods, CompilationTestData testData, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Compilation.EmitDifference(EmitBaseline baseline, IEnumerable1 edits, Func2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, ICollection1 updatedMethods, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.EditAndContinue.EditSession.d__39.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject) --- End of inner exception stack trace --- ---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamespace(NamespaceSymbol namespace) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamespace(NamespaceSymbol namespace) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamespace(NamespaceSymbol namespace) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamespace(NamespaceSymbol namespace) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.VisitNamedType(NamedTypeSymbol sourceType) at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.Accept[TResult](CSharpSymbolVisitor1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSymbolVisitor1.Visit(Symbol symbol) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MatchSymbols.Visit(Symbol symbol) at Microsoft.CodeAnalysis.CSharp.Emit.CSharpSymbolMatcher.MapReference(ITypeReference reference) at Microsoft.CodeAnalysis.Emit.EncVariableSlotAllocator.GetPreviousLocal(ITypeReference currentType, ILocalSymbolInternal currentLocalSymbol, String nameOpt, SynthesizedLocalKind kind, LocalDebugId id, LocalVariableAttributes pdbAttributes, LocalSlotConstraints constraints, ImmutableArray1 dynamicTransformFlags, ImmutableArray1 tupleElementNames) at Microsoft.CodeAnalysis.CodeGen.LocalSlotManager.DeclareLocalImpl(ITypeReference type, ILocalSymbolInternal symbolOpt, String nameOpt, SynthesizedLocalKind kind, LocalDebugId id, LocalVariableAttributes pdbAttributes, LocalSlotConstraints constraints, ImmutableArray1 dynamicTransformFlags, ImmutableArray1 tupleElementNames) at Microsoft.CodeAnalysis.CodeGen.LocalSlotManager.DeclareLocal(ITypeReference type, ILocalSymbolInternal symbol, String name, SynthesizedLocalKind kind, LocalDebugId id, LocalVariableAttributes pdbAttributes, LocalSlotConstraints constraints, ImmutableArray1 dynamicTransformFlags, ImmutableArray1 tupleElementNames, Boolean isSlotReusable) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.DefineLocal(LocalSymbol local, SyntaxNode syntaxNode) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(ImmutableArray1 statements) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementList(BoundStatementList list) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatement(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl() at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(PEModuleBuilder moduleBuilder, MethodSymbol method, Int32 methodOrdinal, BoundStatement block, ImmutableArray1 lambdaDebugInfo, ImmutableArray1 closureDebugInfo, StateMachineTypeSymbol stateMachineTypeOpt, VariableSlotAllocator variableSlotAllocatorOpt, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, ImportChain importChainOpt, Boolean emittingPdb, Boolean emitTestCoverageData, ImmutableArray1 dynamicAnalysisSpans) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamedType(NamedTypeSymbol symbol, TypeCompilationState arg) at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor2 visitor, TArgument argument) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamespace(NamespaceSymbol symbol, TypeCompilationState arg) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor2 visitor, TArgument argument) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamespace(NamespaceSymbol symbol, TypeCompilationState arg) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor2 visitor, TArgument argument) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.VisitNamespace(NamespaceSymbol symbol, TypeCompilationState arg) at Microsoft.CodeAnalysis.CSharp.Symbols.NamespaceSymbol.Accept[TArgument,TResult](CSharpSymbolVisitor2 visitor, TArgument argument) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamespace(NamespaceSymbol symbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethodBodies(CSharpCompilation compilation, PEModuleBuilder moduleBeingBuiltOpt, Boolean emittingPdb, Boolean emitTestCoverageData, Boolean hasDeclarationErrors, DiagnosticBag diagnostics, Predicate1 filterOpt, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CompileMethods(CommonPEModuleBuilder moduleBuilder, Boolean emittingPdb, Boolean emitMetadataOnly, Boolean emitTestCoverageData, DiagnosticBag diagnostics, Predicate1 filterOpt, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Compilation.Compile(CommonPEModuleBuilder moduleBuilder, Boolean emittingPdb, DiagnosticBag diagnostics, Predicate1 filterOpt, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.CSharp.Emit.EmitHelpers.EmitDifference(CSharpCompilation compilation, EmitBaseline baseline, IEnumerable1 edits, Func2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, ICollection1 updatedMethods, CompilationTestData testData, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.EmitDifference(EmitBaseline baseline, IEnumerable1 edits, Func2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, ICollection1 updatedMethods, CompilationTestData testData, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Compilation.EmitDifference(EmitBaseline baseline, IEnumerable1 edits, Func2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, ICollection1 updatedMethods, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.EditAndContinue.EditSession.d__39.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)<--- ' Raa.Storage 1 Active

tmat commented 6 years ago

Waiting for Watson info: 591d4772-ce14-27dd-32f2-221b9851c5a3, 8e729602-d9c5-5b71-dec9-a89234dac76d

sun2sirius commented 6 years ago

Both VS2015 Update 3 and VS2017 v15.7.5 (Professional) are broken in this way - is there really no solution? VS2013 does not have this problem, so to debug my C# code I have to go back to VS2013.

tmat commented 6 years ago

@sun2sirius Can you share a solution where you can reproduce this problem along with what edit are you making that causes it?

Markus1980Wien commented 6 years ago

I don't know if this helps, but after removing the NuGet-packages for the newest .NET framework components like 'Microsoft.AspNet.Mvc', 'Microsoft.AspNet.WebApi', or 'Microsoft.AspNet.WebPages', ... and using the dlls that were shipped with the latest version of the .NET Framework I was able to edit and continue again. So for me removing these NuGet-packages helped.