Intermittent C# Compiler failure

Nabialek, Sam 0 Reputation points

Anyone seen the error below? I'm seeing this in a sub-project of a large build. It doesn;t always happen but it does seem to happen on the same component each time. I've not been able to get it to repeat reliably, ideas????

FWIW. It's a .NET Framework 4.8 Desktop project. C# coding from C#2 - C'# 7.3 are applied

 Unhandled Exception: System.AccessViolationException: Attempted to read or wri
    at Microsoft.Build.BackEnd.NativeMethods.CreateProcess(String lpApplication
    at Microsoft.Build.BackEnd.NodeLauncher.StartInternal(String msbuildLocatio
    at Microsoft.Build.BackEnd.NodeLauncher.<>c__DisplayClass3_0.<Star
    at Microsoft.Build.BackEnd.NodeLauncher.DisableMSBuildServer(Func`1 func)</
    at Microsoft.Build.BackEnd.NodeLauncher.Start(String msbuildLocation, Strin
    at Microsoft.Build.BackEnd.NodeProviderOutOfProcBase.&lt;&gt;c__DisplayClas
    at Microsoft.Build.BackEnd.NodeProviderOutOfProcBase.&lt;&gt;c__DisplayClas
    at System.Threading.Tasks.Parallel.&lt;&gt;c__DisplayClass17_0`1.&lt;ForWor
    at System.Threading.Tasks.Task.InnerInvoke()</message>
    at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)</message>
    at System.Threading.Tasks.Task.&lt;&gt;c__DisplayClass176_0.&lt;ExecuteSelf
    at System.Threading.Tasks.Task.InnerInvoke()</message>
    at System.Threading.Tasks.Task.Execute()</message>
    at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)</messag
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext execution
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task&amp; currentTask
    at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution
    at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.Execute
    at System.Threading.ThreadPoolWorkQueue.Dispatch()</message>
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()</message>
Microsoft Technologies based on the .NET software framework.
3,626 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiale Xue - MSFT 42,816 Reputation points Microsoft Vendor

    Hi @Nabialek, Sam , Welcome to Microsoft Q&A,

    This error message means that your .NET Framework 4.8 desktop project encountered a System.AccessViolationException exception during the build process. This exception is typically caused by an attempt to read or write protected memory. Make sure all third-party libraries and dependencies are up to date. Check if there are similar memory operations or multi-threaded operations in your code to ensure their safety:

    // Example: Check memory access
    IntPtr ptr = IntPtr.Zero;
        ptr = Marshal.AllocHGlobal(size);
        // Execute operation
    catch (Exception ex)
        Console.WriteLine($"Exception: {ex.Message}");
        if (ptr != IntPtr.Zero)
    // Example: Thread synchronization
    private static readonly object lockObject = new object();
    void SafeMethod()
        lock (lockObject)
            // Thread-safe operation

    Best Regards,


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.