microsoft/aspire · error · InvalidOperationException
BrowserMessageStrings.BrowserLogsProfileRequiresSharedUserDa…
Error message
BrowserMessageStrings.BrowserLogsProfileRequiresSharedUserDataMode
What it means
The 'Isolated' user-data mode launches the browser with a fresh, throwaway user-data directory, which is fundamentally incompatible with a named profile: a profile implies a persistent, shared user-data root. When Resolve sees UserDataMode.Isolated together with a non-null profile, it throws using the localized string BrowserLogsProfileRequiresSharedUserDataMode, listing the offending profile and the relevant configuration keys.
Solutions
- Change the user-data mode to 'Shared' when a profile is specified: UserDataModeConfigurationKey = "Shared".
- Or remove the profile entry to keep Isolated mode with a throwaway user-data directory.
- Audit all configuration layers (explicit, resource-level, global) for conflicting keys from different sources.
- If you need isolation per run, drop the named profile and rely on Isolated alone.
Example fix
// before
.WithBrowserLogs(new Dictionary<string, string?> {
["profile"] = "work",
["userdatamode"] = "Isolated" // conflicts with profile
})
// after
.WithBrowserLogs(new Dictionary<string, string?> {
["profile"] = "work",
["userdatamode"] = "Shared"
}) Defensive patterns
Strategy: validation
Validate before calling
var profile = config["profile"];
var mode = config["userdatamode"];
if (profile is { } && string.Equals(mode, "Isolated", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException("Profile requires userdatamode=Shared."); Try / catch
try { BrowserConfiguration.Resolve(...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Shared"))
{ logger.LogError(ex, "Profile and Isolated user-data mode are mutually exclusive"); throw; } Prevention
- Treat profile + Isolated as mutually exclusive in any config templating.
- Centralize browser-logs config in one place instead of merging snippets from multiple layers.
- Prefer Shared mode whenever a named profile is required.
When it happens
Trigger: Calling WithBrowserLogs with both a profile entry (ProfileConfigurationKey set) and userdata mode 'Isolated' (UserDataModeConfigurationKey = "Isolated"), whether both come from explicit values or from a mix of config layers.
Common situations: Combining a team-shared profile config with an isolated-mode default set elsewhere; trying to sandbox a named profile believing Isolated gives extra isolation; merging snippets where one sets profile and another sets isolated mode.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- BrowserMessageStrings.BrowserLogsEmptyBrowserConfiguration
- BrowserMessageStrings.BrowserLogsEmptyProfileConfiguration
- BrowserMessageStrings.BrowserLogsInvalidUserDataModeConfigur…
- BrowserMessageStrings.BrowserLogsTrackedBrowserProfileConfli…
- Cannot resolve the isolated browser user data directory…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/317a688254554f8c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Browsers/BrowserConfiguration.cs:67
// Resolve user-data mode before browser so the browser default can prefer Edge for shared state and Chrome for
// disposable isolated state.
var resolvedProfile = ResolveProfile(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection);
var resolvedUserDataMode = ResolveUserDataMode(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection);
var resolvedBrowser = ResolveBrowser(explicitValues, resourceRuntimeConfiguration, globalRuntimeConfiguration, resourceSection, browserLogsSection, resolvedUserDataMode);
if (string.IsNullOrWhiteSpace(resolvedBrowser))
{
throw new InvalidOperationException(BrowserMessageStrings.BrowserLogsEmptyBrowserConfiguration);
}
if (resolvedProfile is not null && string.IsNullOrWhiteSpace(resolvedProfile))
{
throw new InvalidOperationException(BrowserMessageStrings.BrowserLogsEmptyProfileConfiguration);
}
if (resolvedUserDataMode == BrowserUserDataMode.Isolated && resolvedProfile is not null)
{
throw new InvalidOperationException(
string.Format(
CultureInfo.CurrentCulture,
BrowserMessageStrings.BrowserLogsProfileRequiresSharedUserDataMode,
BrowserLogsBuilderExtensions.ProfileConfigurationKey,
resolvedProfile,
BrowserLogsBuilderExtensions.UserDataModeConfigurationKey,
BrowserUserDataMode.Isolated,
BrowserUserDataMode.Shared));
}
// Stable per-AppHost key sourced from DistributedApplicationBuilder. Only Isolated mode actually needs it
// (its user-data path includes the AppHost segment), but it is always captured here so the registry never
// has to re-read configuration. The same SHA value is used for other per-AppHost persisted state.
var appHostKey = configuration["AppHost:PathSha256"];
return new BrowserConfiguration(resolvedBrowser, resolvedProfile, resolvedUserDataMode, appHostKey);
}
View on GitHub (pinned to 25830f84bd)