microsoft/aspire · error · InvalidOperationException

Browser profile ' ' matched multiple Chromium profiles…

Error message

Browser profile '{0}' matched multiple Chromium profiles under '{1}'. Specify the profile directory name instead.

What it means

TryResolveProfileDirectory throws this when the given profile value matches a profile display name that maps to more than one profile directory under the user data directory. Because Chromium display names are not unique, the library refuses to pick arbitrarily and demands the stable directory name instead.

Solutions

  1. Pass the profile's directory name (e.g., 'Profile 1', 'Default') instead of its display name.
  2. Find the directory name via chrome://version (Profile Path) or by inspecting Local State's info_cache.
  3. Rename one of the duplicate profiles in Chrome to make display names unique.
  4. Catch this exception and prompt the user to disambiguate by directory name.

Example fix

// before
var dir = resolver.ResolveProfileDirectory(userData, "Work"); // two profiles named 'Work'
// after
var dir = resolver.ResolveProfileDirectory(userData, "Profile 2"); // stable directory name
Defensive patterns

Strategy: validation

Validate before calling

var matchingDirs = Directory.GetDirectories(userDataDirectory)
    .Where(d => !Path.GetFileName(d).Equals(profile, StringComparison.Ordinal))
    .Where(d => IsDisplayName(d, profile)) // via Local State metadata
    .ToList();
if (matchingDirs.Count > 1)
{
    throw new ArgumentException($"'{profile}' is ambiguous; use a directory name instead.");
}

Try / catch

try
{
    var dir = resolver.ResolveProfileDirectory(userData, profile);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("matched multiple"))
{
    // ask the user which directory-backed profile to use
}

Prevention

When it happens

Trigger: Calling ResolveProfileDirectory with a display name (from Local State's profile metadata) that two or more profile directories share; the code path detects match != profileEntry.Name for multiple entries.

Common situations: Two Chrome profiles both named 'Work' or 'Personal' (common after profile duplication); users renaming profiles to identical labels; automated tooling resolving profiles by human-readable name.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs:146

            return null;
        }

        string? match = null;

        foreach (var profileEntry in infoCacheElement.EnumerateObject())
        {
            // Ignore stale metadata entries whose profile directories no longer exist.
            if (!Directory.Exists(Path.Combine(userDataDirectory, profileEntry.Name)) ||
                !MatchesBrowserProfile(profileEntry, profile))
            {
                continue;
            }

            // Profile display names are not unique. Force the caller to use the stable directory name when ambiguity
            // would otherwise select an arbitrary profile.
            if (match is not null && !string.Equals(match, profileEntry.Name, StringComparison.Ordinal))
            {
                throw new InvalidOperationException(
                    string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsAmbiguousProfile, profile, userDataDirectory));
            }

            match = profileEntry.Name;
        }

        return match;
    }

    internal static IReadOnlyList<ChromiumBrowserProfile> GetAvailableProfiles(string userDataDirectory)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(userDataDirectory);

        if (!Directory.Exists(userDataDirectory))
        {
            return [];
        }

View on GitHub (pinned to 25830f84bd)