PrismLibrary/Prism · error · InvalidOperationException
Resources.DeactiveNotPossibleException
Error message
Resources.DeactiveNotPossibleException
What it means
AllActiveRegion keeps every added view active, so it has no notion of deactivation; its Deactivate override unconditionally throws InvalidOperationException with Resources.DeactiveNotPossibleException. This is a deliberate API contract: if you need per-view activation states, use a SingleActiveRegion instead.
Solutions
- Use a SingleActiveRegion (e.g., RegisterViewWithRegion with a region whose adapter supports activation) if you need Deactivate semantics.
- Remove the Deactivate call and rely on Region.Remove(view) if the view should disappear entirely.
- Guard polymorphic code: only call Deactivate when the region actually supports it.
- Keep the view in the region and manage visibility through your own mechanism if AllActiveRegion behavior is required.
Example fix
// before
region.Deactivate(myView); // region is AllActiveRegion -> throws
// after
if (region is AllActiveRegion)
region.Remove(myView);
else
region.Deactivate(myView); Defensive patterns
Strategy: type-guard
Validate before calling
if (region is AllActiveRegion)
throw new InvalidOperationException("This region keeps all views active; Deactivate is not supported."); Type guard
bool SupportsDeactivate(IRegion region) => region is not AllActiveRegion;
Try / catch
try
{
region.Deactivate(view);
}
catch (InvalidOperationException ex) when (region is AllActiveRegion)
{
logger.LogWarning("Deactivate unsupported on AllActiveRegion; removing view instead.");
region.Remove(view);
} Prevention
- Know which region type each region name maps to
- Use SingleActiveRegion when per-view activation is needed
- Guard polymorphic Deactivate calls on IRegion
When it happens
Trigger: Calling region.Deactivate(view) on a region instance that is an AllActiveRegion — typically via IRegionManager region lookup, IRegion.ActiveViews manipulation, or view lifecycle code that assumes deactivation is supported.
Common situations: Tab-like UIs where developers expect to hide views but the region was registered with AllActiveRegion; code shared between regions of different kinds calling Deactivate polymorphically; migrating code from SingleActiveRegion to AllActiveRegion.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Resources.HostControlCannotBeSetAfterAttach
- Resources.HostControlCannotBeSetAfterAttach
- The HostControl property cannot be set after Attach method…
- The HostControl property cannot be set after Attach method…
- Cannot create navigation target
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/f846fb58addb13c1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Wpf/Prism.Wpf/Navigation/Regions/AllActiveRegion.cs:23
/// <summary>
/// Region that keeps all the views in it as active. Deactivation of views is not allowed.
/// </summary>
public class AllActiveRegion : Region
{
/// <summary>
/// Gets a readonly view of the collection of all the active views in the region. These are all the added views.
/// </summary>
/// <value>An <see cref="IViewsCollection"/> of all the active views.</value>
public override IViewsCollection ActiveViews => Views;
/// <summary>
/// Deactivate is not valid in this Region. This method will always throw <see cref="InvalidOperationException"/>.
/// </summary>
/// <param name="view">The view to deactivate.</param>
/// <exception cref="InvalidOperationException">Every time this method is called.</exception>
public override void Deactivate(object view)
{
throw new InvalidOperationException(Resources.DeactiveNotPossibleException);
}
}
}
View on GitHub (pinned to 358118cd64)