dotnet/wpf · error · ArgumentException
SR.Image_CantBeFrozen
Error message
SR.Image_CantBeFrozen
What it means
The BitmapVisualManager constructor throws ArgumentException with SR.Image_CantBeFrozen when the supplied RenderTargetBitmap is frozen (Freezable.IsFrozen == true). A frozen target is immutable, so a manager whose purpose is to render into it cannot work.
Solutions
- Pass a mutable (non-frozen) RenderTargetBitmap to the constructor.
- Do not Freeze() the bitmap if it will be a render target; freeze only copies/outputs.
- Clone the frozen bitmap (RenderTargetBitmap.Clone()) if you need a writable copy for rendering.
Example fix
// before bitmap.Freeze(); var mgr = new BitmapVisualManager(bitmap); // throws // after var mgr = new BitmapVisualManager(bitmap); // keep mutable while rendering // ... render ... bitmap.Freeze(); // only after rendering completes
Defensive patterns
Strategy: validation
Validate before calling
if (bitmapTarget == null) throw new ArgumentNullException(nameof(bitmapTarget));
if (bitmapTarget.IsFrozen)
throw new ArgumentException("render target must not be frozen", nameof(bitmapTarget)); Type guard
bool IsRenderable(RenderTargetBitmap bmp) => bmp != null && !bmp.IsFrozen;
Try / catch
try { var mgr = new BitmapVisualManager(rtBitmap); } catch (ArgumentException) { rtBitmap = rtBitmap.Clone(); var mgr = new BitmapVisualManager(rtBitmap); } Prevention
- Never Freeze() a bitmap used as a render target
- Freeze only after all rendering is complete
- Watch resource-dictionary sharing that may auto-freeze
When it happens
Trigger: new BitmapVisualManager(someRenderTargetBitmap) where the bitmap was frozen via Freeze() or obtained from a frozen/shared freezable resource.
Common situations: Sharing a cached RenderTargetBitmap declared in a resource dictionary with freeze enabled, or explicitly freezing for thread-safety before handing it to the manager.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Current DocumentSequence, FixedDocument, or FixedPage not…
- IAmbientProvider
- IAnimatable_CantAnimateSealedDO
- Image_EncoderNoColorContext
- Image_EncoderNoGlobalMetadata
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/eed32d5fafad49c1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/BitmapVisualManager.cs:32
/// </summary>
internal class BitmapVisualManager : DispatcherObject
{
#region Constructors
private BitmapVisualManager()
{
}
/// <summary>
/// Create an BitmapVisualManager for drawing a visual to the bitmap.
/// </summary>
/// <param name="bitmapTarget">Where the resulting bitmap is rendered</param>
public BitmapVisualManager(RenderTargetBitmap bitmapTarget)
{
ArgumentNullException.ThrowIfNull(bitmapTarget);
if (bitmapTarget.IsFrozen)
{
throw new ArgumentException(SR.Format(SR.Image_CantBeFrozen, null));
}
_bitmapTarget = bitmapTarget;
}
#endregion
#region Public methods
/// <summary>
/// Render visual to printer.
/// </summary>
/// <param name="visual">Root of the visual to render</param>
public void Render(Visual visual)
{
Render(visual, Matrix.Identity, Rect.Empty);
}
/// <summary>View on GitHub (pinned to 81131a70a4)