PrismLibrary/Prism · error · ArgumentNullException
ArgumentNullException(nameof(target))
Error message
ArgumentNullException(nameof(target))
What it means
The same RequestNavigate(string target, callback) overload validates target immediately after validating navigation; passing a null target string throws ArgumentNullException(nameof(target)). Prism parses the string into a Uri (RelativeOrAbsolute) right after the check.
Solutions
- Validate the target string before calling (string.IsNullOrEmpty) and fall back to a default view.
- Fix the source producing the null name (binding, config, navigation parameter).
- Use nameof(SomeView) or constants for view names instead of dynamic strings.
Example fix
// before
var target = navParams["destination"] as string;
region.RequestNavigate(target, r => {}); // target may be null
// after
var target = navParams["destination"] as string ?? "Home";
region.RequestNavigate(target, r => {}); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(target))
target = "Home"; // default view Try / catch
try { region.RequestNavigate(target, r => {}); }
catch (ArgumentNullException ex) { logger.LogWarning(ex, "Null navigation target"); } Prevention
- Coalesce dynamic targets to a default view name.
- Use nameof(View) or constants for view names.
- Validate config/bound values feeding navigation targets.
When it happens
Trigger: Calling RequestNavigate(navigation, null, callback) — commonly when the target view name is built dynamically (from a binding, config value, or method result) and evaluates to null.
Common situations: Navigation target taken from a bound property, query-string value, or settings key that is unset; string interpolation that produced null via ToString of null object in older code paths.
Related errors
- ArgumentNullException(nameof(navigation))
- ArgumentNullException for 'regionName'
- ArgumentNullException for 'regionTarget'
- ArgumentNullException for 'target'
- ArgumentNullException for 'view'
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/62ca363c6ac4ef38.
Report an issue: GitHub.
Appendix: source
Thrown at src/Prism.Core/Navigation/Regions/NavigationAsyncExtensions.cs:46
/// <param name="target">The navigation target</param>
public static void RequestNavigate(this INavigateAsync navigation, string target)
{
RequestNavigate(navigation, target, nr => { });
}
/// <summary>
/// Initiates navigation to the target specified by the <paramref name="target"/>.
/// </summary>
/// <param name="navigation">The navigation object.</param>
/// <param name="target">The navigation target</param>
/// <param name="navigationCallback">The callback executed when the navigation request is completed.</param>
public static void RequestNavigate(this INavigateAsync navigation, string target, Action<NavigationResult> navigationCallback)
{
if (navigation == null)
throw new ArgumentNullException(nameof(navigation));
if (target == null)
throw new ArgumentNullException(nameof(target));
var targetUri = new Uri(target, UriKind.RelativeOrAbsolute);
navigation.RequestNavigate(targetUri, navigationCallback);
}
/// <summary>
/// Initiates navigation to the target specified by the <see cref="Uri"/>.
/// </summary>
/// <param name="navigation">The navigation object.</param>
/// <param name="target">The navigation target</param>
public static void RequestNavigate(this INavigateAsync navigation, Uri target)
{
if (navigation == null)
throw new ArgumentNullException(nameof(navigation));
navigation.RequestNavigate(target, nr => { });
}View on GitHub (pinned to 358118cd64)