| Previous | Next |
| CLASS_E_NOTLICENSED | REGDB_E_READREGDB |
VIEW_E_DRAW
Error drawing view
When Windows returns VIEW_E_DRAW—HRESULT 2147746112, 0x80040140, signed -2147221184—AllStat describes the condition as “Error drawing view”. The actionable meaning is IViewObject accepted the view request but failed while rendering it. The surrounding operation is drawing an OLE object into a supplied device context.
The high bit in 0x80040140 is set, so this is a failure rather than a success or informational result. Its facility field is 4 (FACILITY_ITF) and its low 16-bit code is 320 (0x0140). Those bit fields classify the value, but they do not identify the failing object by themselves; the native method, object identity, and first producer of this result remain essential.
Precise failure point
Understanding this result requires this subsystem context: Rendering crosses object, container, and GDI boundaries. A useful incident record must show which side supplied every device context and rectangle, because repainting the same object with a newly valid target is different from repairing the object server.
- Associate this result with one exact operation in IViewObject::Draw and the container-supplied drawing context, bounds, aspect, target device, and continuation callback.
- Confirm that this result came from drawing an OLE object into a supplied device context, rather than from cleanup or a wrapper that ran afterward.
- Preserve any IErrorInfo, underlying Win32 result, provider message, or callback failure that preceded it; the HRESULT alone should not erase a more specific cause.
Diagnostic evidence
A useful incident records the requested DVASPECT, lindex, target device, HDC types, logical bounds, mapping mode, continuation callback result, object state, and rendering fallback used. Also retain the application and component build, architecture, process and thread IDs, COM apartment, operation correlation ID, elapsed time, and the first state-changing event before the failure. When logging it, redact content and credentials while preserving types, lengths, hashes, opaque identities, and lifecycle generations needed to reproduce its contract.
- log the target HDC type, bounds, aspect, lindex, and continuation callback.
- test drawing to a memory DC to separate object rendering from printer or display behavior.
- capture server exceptions, linked-source state, and whether cached presentation data can be used.
Resolution path
- Capture it at the first native return before a wrapper maps it to a generic exception.
- Identify the exact object, method, and lifecycle phase involved in drawing an OLE object into a supplied device context.
- Reproduce it with one controlled input or state change, and verify that the correction changes the decisive evidence rather than merely hiding the result.
Distinct causes
- It can result when the object cannot render the requested state or presentation data.
- It can result when the target or information HDC is invalid, incompatible, or already torn down.
- It can result when the object server fails during drawing, including a reentrant callback or unavailable linked source.
Retry policy
Correction. for it, fall back to a valid cached presentation, recreate the drawing context, or repair the object server while preserving the container layout. Retry boundary. Retry only with changed rendering state or a fresh DC; avoid tight repaint loops that repeatedly invoke the failing server. Before repeating the operation, restore every HDC and selected GDI object, discard only the failed presentation, and preserve a previously valid cache until a replacement render succeeds.
Practical scenario
A print preview asks an embedded object to draw into a printer DC that disappeared after device reconfiguration; recreating the DC and retrying once succeeds. This isolates it within OLE object presentation rendering and provides a regression test for the stated correction.
Difference from related HRESULTs
DV_E_DVASPECT rejects the requested presentation category before drawing; it reports failure after the drawing contract was entered. Keep those outcomes separate in exception mappings, telemetry dimensions, user messages, and automated retry policy.
Developer and administrator guidance
Validate aspect, lindex, target device, drawing bounds, mapping mode, and continuation callbacks at the IViewObject boundary. Regression coverage for it should include screen, printer, metafile, and thumbnail targets; empty or extreme bounds; cancellation callbacks; absent interfaces; and fallback to cached or application-provided rendering.
Operational repair for it must target the evidence-backed owner: compare the object server and presentation-handler versions and reproduce with a known-good host before reinstalling the component that actually owns rendering. Retain before-and-after traces for it so the change can be attributed and reversed.
References
- Microsoft: generic COM error codes
- Microsoft: HRESULT values
- Microsoft: IViewObject::Draw
- Microsoft: IViewObject
Looking for a different code? Search another status or error code.
