Roslyn: C# 7 compiler crash / error -2146232797

Created on 2 May 2017  路  14Comments  路  Source: dotnet/roslyn

Version Used:
Original VS2017 compiler, as well as the 2.1 NuGet compiler package.

Steps to Reproduce:
This is where it gets tricky, it only happens in one (corporation-owned) project that has a very large class, and that heavily uses the new C# 7 features (value tuples and nested functions). And multiple-level nested lambda functions. I've also tried splitting the larger functions into smaller ones to limit the amount of compiler generated items per function but it didn't help any.

Issue Description:
When I change a specific old-style inner function (Func<..>) to the new style, I get this compiler output:

Build started ...
C:\trugit\ICD Manager\packages\Microsoft.Net.Compilers.2.1.0\tools\Microsoft.CSharp.Core.targets(71,5): error MSB6006: "csc.exe" exited with code -2146232797.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

You can notice the compiler used is 2.1 from the proper NuGet package. The line in question is this:

bool messageconnected (string msgname, char dir) =>
     !((connectionstatus.CanBusConnection.TryGetValue((msgname, portname), out ConnectionOrigin connection)
         && (!connection.Connected || (connection.OriginApplication != null && (dir == 'O' || dir == 'B') && connection.OriginApplication != appname)))
         || connection == null);

However that's obviously not a self contained example. And other similar pieces of code work (there's one for each bus type). This one however either makes the compiler return that error code or just plain crash.

Also noticed is that sometimes the compiler will give that exit code and something about FilesWritten being empty: https://i.imgur.com/REHzOHX.png. Compiling again works fine. That's just weird.

Anyway I understand that there are logs I can provide that don't include the source code in question. If so let me know, I'll be happy to help.

Area-Compilers Bug Resolution-Duplicate

All 14 comments

Have a look in eventvwr.msc -> Windows Logs -> Application and see if there's a stack trace. MS doesn't make it easy to find the stack trace and prefer Environment.FailFast

@0xd4d Yeah, found it (it looks funky because of the backtick used in the generic dictionary instance):

Application: csc.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitLocalLoad(BoundLocal local, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoadReceiver(BoundExpression receiver) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoad(BoundFieldAccess fieldAccess, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReceiverRef(BoundExpression receiver, Boolean isAccessConstrained) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoad(BoundFieldAccess fieldAccess, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReceiverRef(BoundExpression receiver, Boolean isAccessConstrained) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCallExpression(BoundCall call, UseKind useKind) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCondBranchCore(BoundExpression condition, Object& dest, Boolean sense) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCondBranch(BoundExpression condition, Object& dest, Boolean sense) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCondBranchCore(BoundExpression condition, Object& dest, Boolean sense) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCondBranch(BoundExpression condition, Object& dest, Boolean sense) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitShortCircuitingOperator(BoundBinaryOperator condition, Boolean sense, Boolean stopSense, Boolean stopValue) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBinaryCondOperator(BoundBinaryOperator binOp, Boolean sense) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReturnStatement(BoundReturnStatement boundReturnStatement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(BoundSequencePoint node) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(ImmutableArray1 statements)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block)
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, ImmutableArray1 dynamicAnalysisSpans) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(TypeCompilationState compilationState) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass20_0.<CompileNamedTypeAsTask>b__0() Stack: at System.Environment.FailFast(System.String, System.Exception) at Microsoft.CodeAnalysis.FatalError.Report(System.Exception, System.Action1)
at Microsoft.CodeAnalysis.FatalError.ReportUnlessCanceled(System.Exception)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass20_0.b__0()
at System.Collections.Generic.Dictionary2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Item(System.__Canon) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitLocalLoad(Microsoft.CodeAnalysis.CSharp.BoundLocal, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoadReceiver(Microsoft.CodeAnalysis.CSharp.BoundExpression) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoad(Microsoft.CodeAnalysis.CSharp.BoundFieldAccess, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReceiverRef(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoad(Microsoft.CodeAnalysis.CSharp.BoundFieldAccess, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReceiverRef(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCallExpression(Microsoft.CodeAnalysis.CSharp.BoundCall, UseKind) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCondBranchCore(Microsoft.CodeAnalysis.CSharp.BoundExpression, System.Object ByRef, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCondBranch(Microsoft.CodeAnalysis.CSharp.BoundExpression, System.Object ByRef, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCondBranchCore(Microsoft.CodeAnalysis.CSharp.BoundExpression, System.Object ByRef, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCondBranch(Microsoft.CodeAnalysis.CSharp.BoundExpression, System.Object ByRef, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitShortCircuitingOperator(Microsoft.CodeAnalysis.CSharp.BoundBinaryOperator, Boolean, Boolean, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBinaryCondOperator(Microsoft.CodeAnalysis.CSharp.BoundBinaryOperator, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReturnStatement(Microsoft.CodeAnalysis.CSharp.BoundReturnStatement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(Microsoft.CodeAnalysis.CSharp.BoundStatement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(Microsoft.CodeAnalysis.CSharp.BoundSequencePoint) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(System.Collections.Immutable.ImmutableArray1)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl()
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.BoundStatement, System.Collections.Immutable.ImmutableArray1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, System.Collections.Immutable.ImmutableArray1, Microsoft.CodeAnalysis.CSharp.StateMachineTypeSymbol, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator, Microsoft.CodeAnalysis.DiagnosticBag, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, Microsoft.CodeAnalysis.CSharp.ImportChain, Boolean, System.Collections.Immutable.ImmutableArray`1)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(Microsoft.CodeAnalysis.CSharp.TypeCompilationState)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass20_0.b__0()
at Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass5_0.b__0()
at System.Threading.Tasks.Task.Execute()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean)
at System.Threading.ThreadPoolWorkQueue.Dispatch()

I just ran into the same issue, here is a small sample to reproduce the crash:

````csharp
class Bug
{
static void Main()
{
var dict = new System.Collections.Generic.Dictionary();

    {
        var folder = "";
        Import<string>(s => s == folder);

        void Import<T>(System.Func<T, bool> _) => dict[""] = folder;
    }
}

}
````

Stacktrace:
Application: csc.exe Framework Version: v4.0.30319 Description: The application requested process termination through System.Environment.FailFast(string message). Message: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitLocalLoad(BoundLocal local, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoadReceiver(BoundExpression receiver) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoad(BoundFieldAccess fieldAccess, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReceiverRef(BoundExpression receiver, Boolean isAccessConstrained) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCallExpression(BoundCall call, UseKind useKind) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(BoundSequencePoint node) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(ImmutableArray`1 statements) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl() at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(PEModuleBuilder moduleBuilder, MethodSymbol method, Int32 methodOrdinal, BoundStatement block, ImmutableArray`1 lambdaDebugInfo, ImmutableArray`1 closureDebugInfo, StateMachineTypeSymbol stateMachineTypeOpt, VariableSlotAllocator variableSlotAllocatorOpt, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, ImportChain importChainOpt, Boolean emittingPdb, ImmutableArray`1 dynamicAnalysisSpans) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(TypeCompilationState compilationState) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass20_0.<CompileNamedTypeAsTask>b__0() Stack: at System.Environment.FailFast(System.String, System.Exception) at Microsoft.CodeAnalysis.FatalError.Report(System.Exception, System.Action`1<System.Exception>) at Microsoft.CodeAnalysis.FatalError.ReportUnlessCanceled(System.Exception) at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass20_0.<CompileNamedTypeAsTask>b__0() at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Item(System.__Canon) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitLocalLoad(Microsoft.CodeAnalysis.CSharp.BoundLocal, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoadReceiver(Microsoft.CodeAnalysis.CSharp.BoundExpression) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoad(Microsoft.CodeAnalysis.CSharp.BoundFieldAccess, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReceiverRef(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCallExpression(Microsoft.CodeAnalysis.CSharp.BoundCall, UseKind) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(Microsoft.CodeAnalysis.CSharp.BoundStatement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(Microsoft.CodeAnalysis.CSharp.BoundSequencePoint) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CSharp.BoundStatement>) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl() at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.BoundStatement, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.ClosureDebugInfo>, Microsoft.CodeAnalysis.CSharp.StateMachineTypeSymbol, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator, Microsoft.CodeAnalysis.DiagnosticBag, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, Microsoft.CodeAnalysis.CSharp.ImportChain, Boolean, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.SourceSpan>) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(Microsoft.CodeAnalysis.CSharp.TypeCompilationState) at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol) at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass20_0.<CompileNamedTypeAsTask>b__0() at Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass5_0.<WithCurrentUICulture>b__0() at System.Threading.Tasks.Task.Execute() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef) at System.Threading.Tasks.Task.ExecuteEntry(Boolean) at System.Threading.ThreadPoolWorkQueue.Dispatch()

I think this, or at least the repro posted by @ThomasKramer , is the same as/similar to my repro. It might be some compounded issue of generics and nested blocks and automatic escalation of ref struct style inlines to delegates with instances:

using System;

class MainClass
{
    static void DoSomething()
    {
        var outerLocal = 0;
        // Open a new block to let the local method live in. Hoisting everything
        // out of this inner block causes the build to succeed.
        {
            var innerLocal = 0;
            void killCsc<T>()
            {
                // Reference an outer local (must be outside of local method鈥檚 directly enclosing block).
                // Removing causes build to succeed
                outerLocal.ToString();

                // Build a lambda capturing an inner local (perhaps this forces escalation of
                // local method implementation from ref struct inline-style to 
                // delegate instance-style?).
                // Removing causes build to succeed.
                Func<int> x = () => innerLocal;
            }

            // Call with one type.
            killCsc<Class1>();

            // Call with another type. Calling with only one type
            // causes build to succeed.
            killCsc<Class2>();
        }
    }
}
class Class1
{
}
class Class2
{
}

My call stack does not look identical, though:

Description: The application requested process termination through System.Environment.FailFast(string message).
Message: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitLocalAddress(BoundLocal localAccess)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitAddress(BoundExpression expression, AddressKind addressKind)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitInstanceFieldAddress(BoundFieldAccess fieldAccess)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCallExpression(BoundCall call, UseKind useKind)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(BoundExpression expression, Boolean used)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(BoundStatement statement)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(BoundSequencePoint node)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(ImmutableArray`1 statements)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl()
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(PEModuleBuilder moduleBuilder, MethodSymbol method, Int32 methodOrdinal, BoundStatement block, ImmutableArray`1 lambdaDebugInfo, ImmutableArray`1 closureDebugInfo, StateMachineTypeSymbol stateMachineTypeOpt, VariableSlotAllocator variableSlotAllocatorOpt, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, ImportChain importChainOpt, Boolean emittingPdb, ImmutableArray`1 dynamicAnalysisSpans)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(TypeCompilationState compilationState)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass20_0.<CompileNamedTypeAsTask>b__0()
Stack:
   at System.Environment.FailFast(System.String, System.Exception)
   at Microsoft.CodeAnalysis.FatalError.Report(System.Exception, System.Action`1<System.Exception>)
   at Microsoft.CodeAnalysis.FatalError.ReportUnlessCanceled(System.Exception)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass20_0.<CompileNamedTypeAsTask>b__0()
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Item(System.__Canon)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitLocalAddress(Microsoft.CodeAnalysis.CSharp.BoundLocal)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitAddress(Microsoft.CodeAnalysis.CSharp.BoundExpression, AddressKind)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitInstanceFieldAddress(Microsoft.CodeAnalysis.CSharp.BoundFieldAccess)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCallExpression(Microsoft.CodeAnalysis.CSharp.BoundCall, UseKind)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(Microsoft.CodeAnalysis.CSharp.BoundStatement)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(Microsoft.CodeAnalysis.CSharp.BoundSequencePoint)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CSharp.BoundStatement>)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock)
   at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl()
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.BoundStatement, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.ClosureDebugInfo>, Microsoft.CodeAnalysis.CSharp.StateMachineTypeSymbol, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator, Microsoft.CodeAnalysis.DiagnosticBag, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, Microsoft.CodeAnalysis.CSharp.ImportChain, Boolean, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.SourceSpan>)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(Microsoft.CodeAnalysis.CSharp.TypeCompilationState)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass20_0.<CompileNamedTypeAsTask>b__0()
   at Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass5_0.<WithCurrentUICulture>b__0()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

I have no generic nested functions, so it might be a different issue that you guys found here.

@myblindy What do you think about this minimal repro I built up from your code? Maybe I鈥檓 wrong in thinking that this error has to do with precisely generics. Are you sure that you haven鈥檛 referenced local variables from an outer scope or tried to create a lambda within the scope of your local function? The line you gave itself doesn鈥檛 create an error for me, but if I carefully construct a program with particular characteristics around it, I can get a crash like yours.

using System;
using System.Collections.Generic;

class KillCsc19182
{
    static void Die()
    {
        // A variable from an outer scope.
        var appname = "asdf";
        {
            // A variable from an inner scope.
            var portname = "http";
            var connectionstatus = new CanConnectionInfo();
            bool messageconnected(string msgname, char dir) =>
                 !((connectionstatus.CanBusConnection.TryGetValue((msgname, portname), out ConnectionOrigin connection)
                     && (!connection.Connected || (connection.OriginApplication != null && (dir == 'O' || dir == 'B') && connection.OriginApplication != appname)))
                     || connection == null);
            messageconnected("a", 'b');

            // Must attempt to create a lambda referencing some variable in the inner block referenced by the local method.
            // For example, accessing appname does not crash, but portname and connectionstatus do.
            Action x = () =>
            {
                if (connectionstatus != null)
                {
                    throw new NotImplementedException();
                }
            };
        }
    }
}

class CanConnectionInfo
{
    public IDictionary<(string, string), ConnectionOrigin> CanBusConnection { get; }
}

class ConnectionOrigin
{
    public bool Connected { get; }
    public string OriginApplication { get; }
}

I鈥檓 going to hazard a guess that the FilesWritten error might be fallout from csc.exe crashing its process. Based on the error message, it sounds like the GenerateResource task is a stub task which tries to write to the magical VBCSCompiler.exe process and then read back results. If this is plausible, that error can be ignored as a distraction from the actual issue as other failures happening when csc.exe dies are OK because csc.exe shouldn鈥檛 ever crash like this.

@myblindy

(it looks funky because of the backtick used in the generic dictionary instance)

btw, you can use fences to escape inline backticks.

@binki it does reference variables from an outer scope inside the same function, but no lambdas further reference the local function. It's really tricky to reproduce and I haven't been able to outside the production code base.

By all means though, the cases you guys presented should absolutely be fixed too! For all I know fixing those will fix my issues too :)

@myblindy

but no lambdas further reference the local function.

To be nit-picky, do you use lambdas at all in the scope where the local function is? The lambdas don鈥檛 have to reference the function but rather some variable in the inner scope. E.g., a linq query referencing a variable in a condition/select expression, lambda passed to another method call?

It鈥檇 be great if you could build a more complete repro from your own code, then maybe we can see if there really is or isn鈥檛 a common root cause. I鈥檓 currently convinced that the compiler crash is only affected by the structure of the method containing the local function itself. So, copy the full method containing the local function is in to a new empty class in an empty solution. Create stubs for the types (classes, etc.) it requires until you stop getting Intellisense errors (Quick Actions might help). At this point, you should have csc crashing when you attempt to build鈥攊f you can鈥檛 get to this step, then that means that the trigger for the bug is not constrained to your method and I鈥檓 wrong xD, which would be helpful to know. Then remove a line/construct at a time from the method until csc stops crashing and then take a step back and see if you can remove anything else with it still crashing.

@binki

do you use lambdas at all in the scope where the local function is?

Yeah, that I do.

I'll try what you suggested, though my method right now has 1018 lines (it's part of a compiler, you know how these things tend to grow). It might take a while until I get something small enough to be useful.

@binki Ok I managed to create a short repro of another instance of the error. The initial instance I mentioned is impossible, too much code.

The project file is here: https://1drv.ms/u/s!AuW49h7benqig68vpKe1of3KG87x7w (Microsoft OneDrive link, dropbox is blocked at work). It's short enough to just paste below, just make sure you add the CsvHelper and System.ValueTuple Nuget packages:

using CsvHelper;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace csc_crash
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var csv = new CsvReader(new StreamReader("")))
            {
                bool IsEmptyRow() => true;
                void SkipEmptyRows() { while (IsEmptyRow() && csv.Read()) ; }
                var mergedbus = new MergedBus();

                new List<string>().Select((busname, idx) => new MergedBusGroup
                {
                    MergedBusObject = mergedbus
                });
            }
        }
    }

    public interface IDbObject
    {
    }

    class MergedBusGroup : IDbObject
    {
        public MergedBus MergedBusObject;
    }

    class MergedBus : IDbObject
    {
    }
}

Pretty much whatever else I've tried removing actually compiles so it should be as minimal as it gets.

Edit: Oh you don't even need ValueTuple, I removed all tuple related code and the crash happens without it too.

Thanks! I鈥檝e managed to pare it down (by removing custom classes) to:

using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        object csv = null;
        {
            bool IsEmptyRow() => true;
            void SkipEmptyRows() { while (IsEmptyRow() && csv != null) ; }
            var mergedbus = new object();

            new List<string>().Select((busname, idx) => mergedbus);
        }
    }
}

I think (but don鈥檛 know enough to prove) that the underlying cause is the same, something with the nested scopes and the compiler doing optimized ref struct style captures versus lambda object captures. All of these repros require a lambda capturing a variable in the inner block and a local method accessing two variables, one from the inner block and another from the outer block.

Now to hope that someone who actually knows how Roslyn works can look at why it鈥檚 crashing xD.

The issue described looks the same as in https://github.com/dotnet/roslyn/issues/16895
It seems to be fixed in master branch and will be included in the next release/update of the compiler.

It is indeed related to a combination of lambda capturing and locals function.

One easy way to confirm whether the issue is fixed is via trying your sample on the "TryRoslyn" website:

https://sharplab.io/

by default, the site uses compiler as of the last release and your sample will cause a crash
If you switch from "Release" to "master", the crash disappears.

UPDATE: I updated my projects to 4.7 framework and the Microsoft.Net.Compilers to v2.9.0 and the problem went away.

Sorry to bother you all.

-David


Bug seems to still be there more than a year later. My project compiled yesterday. Made a bunch of edits today. Now the build of the project fails.

Solution enables 'unsafe' code. The project that fails is a dll project that uses unsafe pointers.

See error stack trace at end of this post.

Running latest VS 2017
See system information after compiler info


Microsoft Visual Studio Professional 2017
Version 15.8.7
VisualStudio.15.Release/15.8.7+28010.2046
Microsoft .NET Framework
Version 4.7.03062

Installed Version: Professional

Visual C++ 2017 00369-60000-00001-AA364
Microsoft Visual C++ 2017

Application Insights Tools for Visual Studio Package 8.13.10627.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.8.05085.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 15.8.31590
Provides languages services for ASP.NET Core Razor.

Azure App Service Tools v3.0.0 15.8.05023.0
Azure App Service Tools v3.0.0

C# Tools 2.9.0-beta8-63208-01
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 15.8.18241.1
Provides tools for finding, instantiating and customizing templates in cookiecutter format.

JavaScript Language Service 2.0
JavaScript Language Service

JavaScript Project System 2.0
JavaScript Project System

JetBrains ReSharper Ultimate 2018.2.2 Build 182.0.20180908.72422
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright 漏 2018 JetBrains, Inc.

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10730.2

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

MLGen Package Extension 1.0
MLGen Package Visual Studio Extension Detailed Info

NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

OzCode 1.0
Your road to Magical Debugging. http://www.oz-code.com

OzCodePackage Extension 1.0
OzCodePackage Visual Studio Extension Detailed Info

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Python 15.8.18241.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Python - Django support 15.8.18241.1
Provides templates and integration for the Django web framework.

Python - IronPython support 15.8.18241.1
Provides templates and integration for IronPython-based projects.

Python - Profiling support 15.8.18241.1
Profiling support for Python projects.

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

TypeScript Tools 15.8.20822.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 2.9.0-beta8-63208-01
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake

Visual Studio Tools for Universal Windows Apps 15.0.28010.2046
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.


OS Name Microsoft Windows 7 Ultimate N
Version 6.1.7601 Service Pack 1 Build 7601
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name
System Manufacturer Dell Inc.
System Model Precision T7610
System Type x64-based PC
Processor Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz, 2601 Mhz, 6 Core(s), 12 Logical Processor(s)
Processor Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz, 2601 Mhz, 6 Core(s), 12 Logical Processor(s)
BIOS Version/Date Dell Inc. A03, 9/5/2013
SMBIOS Version 2.7
Windows Directory C:\Windows
System Directory C:\Windows\system32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "6.1.7601.24231"
User Name
Time Zone Eastern Daylight Time
Installed Physical Memory (RAM) 64.0 GB
Total Physical Memory 63.9 GB
Available Physical Memory 48.3 GB
Total Virtual Memory 128 GB
Available Virtual Memory 111 GB
Page File Space 63.9 GB
Page File C:\pagefile.sys


-David

Here's my events application error log:

Application: csc.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitLocalLoad(BoundLocal local, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoadReceiver(BoundExpression receiver) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoad(BoundFieldAccess fieldAccess, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReceiverRef(BoundExpression receiver, Boolean isAccessConstrained) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCallExpression(BoundCall call, UseKind useKind) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitAssignmentExpression(BoundAssignmentOperator assignmentOperator, UseKind useKind) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(BoundExpression expression, Boolean used) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(BoundStatement statement) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(BoundSequencePointWithSpan node) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(ImmutableArray1 statements)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitTryStatement(BoundTryStatement statement, Boolean emitCatchesOnly)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitTryStatement(BoundTryStatement statement, Boolean emitCatchesOnly)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(ImmutableArray1 statements) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(BoundBlock block) 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, ImmutableArray1 dynamicAnalysisSpans)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(TypeCompilationState compilationState)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass20_0.b__0()
Stack:
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.CodeAnalysis.FatalError.Report(System.Exception, System.Action1<System.Exception>) at Microsoft.CodeAnalysis.FatalError.ReportUnlessCanceled(System.Exception) at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass20_0.<CompileNamedTypeAsTask>b__0() at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Item(System.__Canon)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitLocalLoad(Microsoft.CodeAnalysis.CSharp.BoundLocal, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoadReceiver(Microsoft.CodeAnalysis.CSharp.BoundExpression)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitFieldLoad(Microsoft.CodeAnalysis.CSharp.BoundFieldAccess, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitReceiverRef(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitCallExpression(Microsoft.CodeAnalysis.CSharp.BoundCall, UseKind)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitAssignmentExpression(Microsoft.CodeAnalysis.CSharp.BoundAssignmentOperator, UseKind)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCore(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpressionCoreWithStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitExpression(Microsoft.CodeAnalysis.CSharp.BoundExpression, Boolean)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatementAndCountInstructions(Microsoft.CodeAnalysis.CSharp.BoundStatement)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitSequencePointStatement(Microsoft.CodeAnalysis.CSharp.BoundSequencePointWithSpan)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(System.Collections.Immutable.ImmutableArray1<Microsoft.CodeAnalysis.CSharp.BoundStatement>) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitTryStatement(Microsoft.CodeAnalysis.CSharp.BoundTryStatement, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitTryStatement(Microsoft.CodeAnalysis.CSharp.BoundTryStatement, Boolean) at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitStatements(System.Collections.Immutable.ImmutableArray1)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.EmitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock)
at Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.GenerateImpl()
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.GenerateMethodBody(Microsoft.CodeAnalysis.CSharp.Emit.PEModuleBuilder, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.BoundStatement, System.Collections.Immutable.ImmutableArray1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, System.Collections.Immutable.ImmutableArray1, Microsoft.CodeAnalysis.CSharp.StateMachineTypeSymbol, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator, Microsoft.CodeAnalysis.DiagnosticBag, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, Microsoft.CodeAnalysis.CSharp.ImportChain, Boolean, System.Collections.Immutable.ImmutableArray`1)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileSynthesizedMethods(Microsoft.CodeAnalysis.CSharp.TypeCompilationState)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol)
at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass20_0.b__0()
at Roslyn.Utilities.UICultureUtilities+<>c__DisplayClass5_0.b__0()
at System.Threading.Tasks.Task.Execute()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean)
at System.Threading.ThreadPoolWorkQueue.Dispatch()

Was this page helpful?
0 / 5 - 0 ratings