PrismLibrary/Prism · error · ArgumentNullException
uri
Error message
uri
What it means
UriParsingHelper.Parse throws ArgumentNullException with parameter name 'uri' when passed a null string. Note the docs say null-or-empty, but the code only checks null; an empty string is passed to new Uri and would fail later.
Solutions
- Ensure a non-null uri string is passed
- Check the value before navigating: if (uri is not null) navigationService.NavigateAsync(uri)
- Fix the binding/data source that produced null
Example fix
// before
await _navigationService.NavigateAsync(_nextUri); // _nextUri null
// after
if (_nextUri is not null)
await _navigationService.NavigateAsync(_nextUri); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(uri))
throw new ArgumentException("uri must be a non-empty string", nameof(uri));
await navigationService.NavigateAsync(uri); Type guard
bool isNavigableUri(string uri) => !string.IsNullOrEmpty(uri);
Try / catch
try { await navigationService.NavigateAsync(uri); }
catch (ArgumentNullException ex) when (ex.ParamName == "uri") { /* fallback navigation */ } Prevention
- Initialize navigation URI properties to defaults
- Null-check command parameters in navigation commands
- Use UriParsingHelper only on verified non-null strings
When it happens
Trigger: Calling UriParsingHelper.Parse(null), typically via NavigationService navigation APIs given a null URI, or CommandParameter-bound URIs that never received a value.
Common situations: XAML bindings to a navigation command whose Uri property was never set; view-model navigation calls with null segment strings after failed configuration.
Related errors
- source
- configureSegment
- Cannot process an absolute Navigation Uri when navigating…
- regionNavigationContentLoader
- navigationCallback
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/3d491d48398f7449.
Report an issue: GitHub.
Appendix: source
Thrown at src/Prism.Core/Common/UriParsingHelper.cs:161
/// <param name="uri">The URI.</param>
public static INavigationParameters ParseQuery(Uri uri)
{
var query = GetQuery(uri);
return new NavigationParameters(query);
}
/// <summary>
/// Parses a uri string to a properly initialized Uri for Prism
/// </summary>
/// <param name="uri">A uri string.</param>
/// <returns>A <see cref="Uri"/>.</returns>
/// <exception cref="ArgumentNullException">Throws an <see cref="ArgumentNullException"/> when the string is null or empty.</exception>
public static Uri Parse(string uri)
{
if (uri == null)
{
throw new ArgumentNullException(nameof(uri));
}
return uri.StartsWith("/", StringComparison.Ordinal)
? new Uri("http://localhost" + uri, UriKind.Absolute)
: new Uri(uri, UriKind.RelativeOrAbsolute);
}
/// <summary>
/// This will provide the existing <see cref="Uri"/> if it is already Absolute, otherwise
/// it will build a new Absolute <see cref="Uri"/>.
/// </summary>
/// <param name="uri">The source <see cref="Uri"/>.</param>
/// <returns>An Absolute <see cref="Uri"/>.</returns>
public static Uri EnsureAbsolute(Uri uri)
{
if (uri.IsAbsoluteUri)
{
return uri;View on GitHub (pinned to 358118cd64)