Site icon EfmSoft

What does HRESULT 0x80040156 (REGDB_E_BADTHREADINGMODEL) mean?

 
Previous Next
REGDB_E_IIDNOTREG REGDB_E_PACKAGEPOLICYVIOLATION

REGDB_E_BADTHREADINGMODEL

Threading model entry is not valid

Windows defines REGDB_E_BADTHREADINGMODEL as 2147746134 (0x80040156; signed value -2147221162). AllStat’s description is “Threading model entry is not valid”. The code marks a specific failure: The InprocServer32 ThreadingModel registration contains an unsupported value. The relevant operation is loading an in-process COM server into a caller apartment.

The high bit in 0x80040156 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 342 (0x0156). 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.

Where it is raised

Understanding this result requires this subsystem context: COM registration is architecture-, scope-, and identity-sensitive. A key visible in Registry Editor is not proof that the failing process sees the same view or that the values form a coherent activation contract.

Telemetry checklist

A useful incident records the CLSID or IID, registry view, process architecture, user or machine hive, server path, ThreadingModel text, package identity, access result, and deployment version. 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.

Why it is specific

Investigation order

  1. Capture it at the first native return before a wrapper maps it to a generic exception.
  2. Identify the exact object, method, and lifecycle phase involved in loading an in-process COM server into a caller apartment.
  3. Reproduce it with one controlled input or state change, and verify that the correction changes the decisive evidence rather than merely hiding the result.

Safe handling

Correction. for it, repair the registration through the component installer and align it with the server’s real threading implementation. Retry boundary. Do not reinterpret the bad value or default silently; retry only after registration is corrected and the server is loaded in a new process. Before repeating the operation, complete or roll back the installer transaction, re-read the exact user or machine registry view, and discard class factories obtained from superseded registration.

Practical scenario

An installer writes “MTA” instead of the documented “Free” value; changing the authored installer data, not the application, resolves activation. This isolates it within COM registration database lookup and activation metadata and provides a regression test for the stated correction.

Difference from related HRESULTs

RPC_E_CHANGED_MODE concerns a thread already initialized with another apartment model; it concerns invalid server registration. Keep those outcomes separate in exception mappings, telemetry dimensions, user messages, and automated retry policy.

Developer and administrator guidance

Treat registration as deployment data, record architecture and scope on every lookup, validate ThreadingModel text, and avoid runtime self-repair that guesses missing keys. Regression coverage for it should include 32-bit and 64-bit views, per-user and per-machine registration, missing and malformed values, packaged and unpackaged activation, access denial, and upgrade rollback.

Operational repair for it must target the evidence-backed owner: use the product’s supported installer or package deployment path and inspect the same registry view as the failing process; do not create CLSID or IID entries from a different machine. Retain before-and-after traces for it so the change can be attributed and reversed.

References


Looking for a different code? Search another status or error code.

Exit mobile version