microsoft/aspire · error · Win32Exception

Failed to invoke InitializeProcThreadAttributeList while…

Error message

Failed to invoke InitializeProcThreadAttributeList while starting tracked browser CDP pipe.

What it means

A Win32Exception wrapping GetLastError from InitializeProcThreadAttributeList in CreateWindowsProcess (BrowserLogsPipeBrowserProcessLauncher.Windows.cs:88). Aspire uses an extended STARTUPINFO attribute list to restrict handle inheritance to exactly the two CDP pipe handles when launching Chromium; failure here means the attribute list could not be prepared, so the browser cannot be started on the pipe transport.

Solutions

  1. Read NativeErrorCode (ex.Message includes the Win32 error) and check system memory availability.
  2. Retry after freeing memory or increasing the machine/container memory limit.
  3. Disable or exclude injective antivirus/EDR hooking of process creation for the AppHost process.
  4. Run the latest Aspire version; if persistent, report at https://github.com/microsoft/aspire/issues with the Win32 error code.
  5. Consider the WebSocket CDP transport as a fallback if the pipe transport cannot start.
Defensive patterns

Strategy: try-catch

Type guard

static bool IsInitAttrListFailure(Win32Exception ex) => ex.Message.Contains("InitializeProcThreadAttributeList");

Try / catch

try
{
    StartBrowserPipeWindows();
}
catch (Win32Exception ex) when (IsInitAttrListFailure(ex))
{
    logger.LogError(ex, "InitializeProcThreadAttributeList failed (Win32 error {Errno}). Check memory and security software.", ex.NativeErrorCode);
    throw;
}

Prevention

When it happens

Trigger: InitializeProcThreadAttributeList returns FALSE during StartWindows — typically ERROR_INSUFFICIENT_BUFFER (size mismatch after AllocHGlobal) or ERROR_NOT_ENOUGH_MEMORY when the heap allocation cannot back the list.

Common situations: Severe memory pressure on the host; corrupted kernel32 state after unusual injection/hooking software (antivirus, App-V); essentially never caused by user configuration.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/bd2ce7dfc0803b0a. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Browsers/BrowserLogsPipeBrowserProcessLauncher.Windows.cs:88

    }

    private static WindowsProcessInfo CreateWindowsProcess(string executablePath, IReadOnlyList<string> arguments, IntPtr[] inheritedHandles)
    {
        var commandLine = Marshal.StringToHGlobalUni(BuildWindowsCommandLine(executablePath, arguments));
        var attributeListSize = UIntPtr.Zero;
        // STARTUPINFOEX + PROC_THREAD_ATTRIBUTE_HANDLE_LIST lets us turn on handle inheritance while limiting it to the
        // two CDP pipe handles. That avoids the broad "all inheritable handles leak into Chromium" behavior of plain
        // CreateProcess(..., inheritHandles: true).
        _ = InitializeProcThreadAttributeList(IntPtr.Zero, 1, 0, ref attributeListSize);
        var attributeList = Marshal.AllocHGlobal((nint)attributeListSize.ToUInt64());
        var handleList = Marshal.AllocHGlobal(IntPtr.Size * inheritedHandles.Length);
        var startupInfoPointer = IntPtr.Zero;

        try
        {
            if (!InitializeProcThreadAttributeList(attributeList, 1, 0, ref attributeListSize))
            {
                throw CreateWindowsException("InitializeProcThreadAttributeList");
            }

            for (var i = 0; i < inheritedHandles.Length; i++)
            {
                Marshal.WriteIntPtr(handleList, i * IntPtr.Size, inheritedHandles[i]);
            }

            if (!UpdateProcThreadAttribute(
                attributeList,
                0,
                s_procThreadAttributeHandleList,
                handleList,
                (UIntPtr)(uint)(IntPtr.Size * inheritedHandles.Length),
                IntPtr.Zero,
                IntPtr.Zero))
            {
                throw CreateWindowsException("UpdateProcThreadAttribute");
            }

View on GitHub (pinned to 25830f84bd)