question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

16.7 causing wpf project to fail with `"csc.exe" exited with code -2146232797`

See original GitHub issue

Version Used: 16.7 (was working fine in 16.6.x)

Steps to Reproduce:

Build the project. The only message I see is

       e.targets(70,5): error MSB6006: "csc.exe" exited with code -2146232797. [C:\path\to\source\Wpf.project\Wpf.project_0egzionw_wpftmp.csproj]

There is a stack trace in the event viewer:

Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.DecisionDagRewriter.WhenClauseMightAssignPatternVariableWalker.MethodMayMutateReceiver(BoundExpression receiver, MethodSymbol method)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.DecisionDagRewriter.WhenClauseMightAssignPatternVariableWalker.VisitPropertyAccess(BoundPropertyAccess node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitNameOfOperator(BoundNameOfOperator node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitBinaryOperator(BoundBinaryOperator node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(BoundExpression node)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32& recursionDepth, BoundExpression node)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.DecisionDagRewriter.WhenClauseMightAssignPatternVariableWalker.MightAssignSomething(BoundExpression expr)
   at System.Linq.ImmutableArrayExtensions.Any[T](ImmutableArray`1 immutableArray, Func`2 predicate)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.DecisionDagRewriter.ShareTempsIfPossibleAndEvaluateInput(BoundDecisionDag decisionDag, BoundExpression loweredSwitchGoverningExpression, ArrayBuilder`1 result, BoundExpression& savedInputExpression)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.SwitchStatementLocalRewriter.LowerSwitchStatement(BoundSwitchStatement node)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.SwitchStatementLocalRewriter.Rewrite(LocalRewriter localRewriter, BoundSwitchStatement node)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitStatement(BoundStatement node)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitPossibleUsingDeclaration(BoundStatement node, ImmutableArray`1 statements, Int32 statementIndex, Boolean& replacedLocalDeclarations)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitStatementSubList(ArrayBuilder`1 builder, ImmutableArray`1 statements, Int32 startIndex)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitBlock(BoundBlock node)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitStatement(BoundStatement node)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.Rewrite(CSharpCompilation compilation, MethodSymbol method, Int32 methodOrdinal, NamedTypeSymbol containingType, BoundStatement statement, TypeCompilationState compilationState, SynthesizedSubmissionFields previousSubmissionFields, Boolean allowOmissionOfConditionalCalls, Boolean instrumentForDynamicAnalysis, ImmutableArray`1& dynamicAnalysisSpans, DebugDocumentProvider debugDocumentProvider, DiagnosticBag diagnostics, Boolean& sawLambdas, Boolean& sawLocalFunctions, Boolean& sawAwaitInExceptionHandler)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.LowerBodyOrInitializer(MethodSymbol method, Int32 methodOrdinal, BoundStatement body, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState, Boolean instrumentForDynamicAnalysis, DebugDocumentProvider debugDocumentProvider, ImmutableArray`1& dynamicAnalysisSpans, DiagnosticBag diagnostics, VariableSlotAllocator& lazyVariableSlotAllocator, ArrayBuilder`1 lambdaDebugInfoBuilder, ArrayBuilder`1 closureDebugInfoBuilder, StateMachineTypeSymbol& stateMachineTypeOpt)
   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.<>c__DisplayClass22_0.<CompileNamedTypeAsync>b__0()
Stack:
   at System.Environment.FailFast(System.String, System.Exception)
   at Microsoft.CodeAnalysis.FailFast.OnFatalException(System.Exception)
   at Microsoft.CodeAnalysis.FatalError.ReportUnlessCanceled(System.Exception)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass22_0.<CompileNamedTypeAsync>b__0()
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter+DecisionDagRewriter+WhenClauseMightAssignPatternVariableWalker.MethodMayMutateReceiver(Microsoft.CodeAnalysis.CSharp.BoundExpression, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter+DecisionDagRewriter+WhenClauseMightAssignPatternVariableWalker.VisitPropertyAccess(Microsoft.CodeAnalysis.CSharp.BoundPropertyAccess)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32 ByRef, Microsoft.CodeAnalysis.CSharp.BoundExpression)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitNameOfOperator(Microsoft.CodeAnalysis.CSharp.BoundNameOfOperator)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32 ByRef, Microsoft.CodeAnalysis.CSharp.BoundExpression)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalker.VisitBinaryOperator(Microsoft.CodeAnalysis.CSharp.BoundBinaryOperator)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeWalkerWithStackGuard.VisitExpressionWithoutStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Microsoft.CodeAnalysis.CSharp.BoundExpression)
   at Microsoft.CodeAnalysis.CSharp.BoundTreeVisitor.VisitExpressionWithStackGuard(Int32 ByRef, Microsoft.CodeAnalysis.CSharp.BoundExpression)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter+DecisionDagRewriter+WhenClauseMightAssignPatternVariableWalker.MightAssignSomething(Microsoft.CodeAnalysis.CSharp.BoundExpression)
   at System.Linq.ImmutableArrayExtensions.Any[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Immutable.ImmutableArray`1<System.__Canon>, System.Func`2<System.__Canon,Boolean>)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter+DecisionDagRewriter.ShareTempsIfPossibleAndEvaluateInput(Microsoft.CodeAnalysis.CSharp.BoundDecisionDag, Microsoft.CodeAnalysis.CSharp.BoundExpression, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.BoundStatement>, Microsoft.CodeAnalysis.CSharp.BoundExpression ByRef)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter+SwitchStatementLocalRewriter.LowerSwitchStatement(Microsoft.CodeAnalysis.CSharp.BoundSwitchStatement)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter+SwitchStatementLocalRewriter.Rewrite(Microsoft.CodeAnalysis.CSharp.LocalRewriter, Microsoft.CodeAnalysis.CSharp.BoundSwitchStatement)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitStatement(Microsoft.CodeAnalysis.CSharp.BoundStatement)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitPossibleUsingDeclaration(Microsoft.CodeAnalysis.CSharp.BoundStatement, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CSharp.BoundStatement>, Int32, Boolean ByRef)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitStatementSubList(Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CSharp.BoundStatement>, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CSharp.BoundStatement>, Int32)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitBlock(Microsoft.CodeAnalysis.CSharp.BoundBlock)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.VisitStatement(Microsoft.CodeAnalysis.CSharp.BoundStatement)
   at Microsoft.CodeAnalysis.CSharp.LocalRewriter.Rewrite(Microsoft.CodeAnalysis.CSharp.CSharpCompilation, Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol, Microsoft.CodeAnalysis.CSharp.BoundStatement, Microsoft.CodeAnalysis.CSharp.TypeCompilationState, Microsoft.CodeAnalysis.CSharp.SynthesizedSubmissionFields, Boolean, Boolean, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.SourceSpan> ByRef, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, Microsoft.CodeAnalysis.DiagnosticBag, Boolean ByRef, Boolean ByRef, Boolean ByRef)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.LowerBodyOrInitializer(Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, Microsoft.CodeAnalysis.CSharp.BoundStatement, Microsoft.CodeAnalysis.CSharp.SynthesizedSubmissionFields, Microsoft.CodeAnalysis.CSharp.TypeCompilationState, Boolean, Microsoft.CodeAnalysis.CodeGen.DebugDocumentProvider, System.Collections.Immutable.ImmutableArray`1<Microsoft.CodeAnalysis.CodeGen.SourceSpan> ByRef, Microsoft.CodeAnalysis.DiagnosticBag, Microsoft.CodeAnalysis.CodeGen.VariableSlotAllocator ByRef, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CodeGen.LambdaDebugInfo>, Microsoft.CodeAnalysis.PooledObjects.ArrayBuilder`1<Microsoft.CodeAnalysis.CodeGen.ClosureDebugInfo>, Microsoft.CodeAnalysis.CSharp.StateMachineTypeSymbol ByRef)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol, Int32, ProcessedFieldInitializers ByRef, Microsoft.CodeAnalysis.CSharp.SynthesizedSubmissionFields, Microsoft.CodeAnalysis.CSharp.TypeCompilationState)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler+<>c__DisplayClass22_0.<CompileNamedTypeAsync>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 tried to get the jit-debugger attached to the csc.exe, but I was unable to (don’t know how). I followed the advise here: https://docs.microsoft.com/en-us/visualstudio/debugger/debug-using-the-just-in-time-debugger?view=vs-2019#jit_errors but I couldn’t get the jit-debugger working.

Expected Behavior: Project compiles

Actual Behavior: Project fails to build with the error:

       e.targets(70,5): error MSB6006: "csc.exe" exited with code -2146232797. [C:\Users\Chase.Wallis\source\Product\Co
       mmon\AdminArsenal.Product.Wpf\AdminArsenal.Product.Wpf_0egzionw_wpftmp.csproj]```

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chasewalliscommented, Aug 12, 2020

This commit 52be8a33ec3fadc5511d46d5b1726bead24c270a didn’t do a null check for receiver.

private static bool MethodMayMutateReceiver(BoundExpression receiver, MethodSymbol method)
{
  return
     method != null &&
     !method.IsStatic &&
     !method.IsEffectivelyReadOnly &&
     receiver.Type?.IsReferenceType == false &&
     // methods of primitive types do not mutate their receiver
     method.ContainingType.SpecialType.IsPrimitiveRecursiveStruct();
}
0reactions
gaftercommented, Sep 3, 2020

Repro here:

struct Outer
{
    struct S
    {
        static void M(string q)
        {
            S s = new S();
            System.Console.Write(s switch
            {
                { P: 1 } when nameof(Q) == q => 1,
                { P: 2 } => 2,
                _ => 3,
            });
        }

        int P => 1;
    }

    public int Q => 1;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

csc.exe exited with code -2146232797 vs 2017
It is nasty, the C# compiler decided to quit with Environment.FailFast(). Try it on a do-nothing C# source file, if it still fails...
Read more >
Unknown Hard Error in csc.exe after upgrading to 16.7.2: ...
Gets a crash in csc with the following message: error MSB6006: "csc.exe" exited with code -2146232797. In the event viewer I get two...
Read more >
error MSB6006: "csc.exe" exited with code -2146232797.
Since upgrading to 16.2, several of our projects are failing to build: C:\Program Files (x86)\Microsoft Visual ...
Read more >
compiler error | Data Distribution Service (DDS) ...
Core.targets(75,5): error MSB6006: "csc.exe" exited with code -2146232797. Any thoughts? Do I need to install an older version of Visual ...
Read more >
Visual Studio error csc exe exited with code 1073741819
So I opened an API project that I literally just added a code to and published yesterday and today when I changed a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found