| Previous | Next |
| REGDB_E_BADTHREADINGMODEL | CAT_E_CATIDNOEXIST |
REGDB_E_PACKAGEPOLICYVIOLATION
A registration in a package violates package-specific policies
The native value 0x80040157 is REGDB_E_PACKAGEPOLICYVIOLATION, unsigned 2147746135 and signed -2147221161. According to AllStat, it means “A registration in a package violates package-specific policies”. Treat it as evidence that a COM registration inside a package violates package-specific policy; the operation in progress is processing packaged COM declarations or package-scoped registration.
The high bit in 0x80040157 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 343 (0x0157). 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.
Operational meaning
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.
- Associate this result with one exact operation in CLSID/IID registry lookup, InprocServer32 or LocalServer32 metadata, interface proxy registration, package policy, and threading-model interpretation.
- Confirm that this result came from processing packaged COM declarations or package-scoped registration, 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.
Cause model
- It can result when the class attempts a registration form not permitted for its package type.
- It can result when the manifest and registry metadata disagree about server, scope, or activation model.
- It can result when an upgrade leaves machine-wide registration that conflicts with package ownership.
Troubleshooting workflow
- 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 processing packaged COM declarations or package-scoped registration.
- Record package family/full name, manifest class declaration, CLSID, server type, and deployment operation.
- Compare the package manifest with supported packaged COM rules.
- Inspect deployment diagnostics and remove only stale registration owned by the previous package version.
- Reproduce it with one controlled input or state change, and verify that the correction changes the decisive evidence rather than merely hiding the result.
What to log
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.
Correction strategy
Correction. for it, correct the package manifest or deployment layout and redeploy the signed package; avoid bypassing policy with manual registry writes. Retry boundary. Retry after package repair or removal of a verified ownership conflict, not after generic re-registration. 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
A package declares an in-process server path outside its installed location; moving the binary into the package and updating the manifest satisfies policy. This isolates it within COM registration database lookup and activation metadata and provides a regression test for the stated correction.
Difference from related HRESULTs
REGDB_E_WRITEREGDB can be a permissions failure; it is an intentional package-policy rejection. 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
- Microsoft: generic COM error codes
- Microsoft: HRESULT values
- Microsoft: registering COM components
- Microsoft: InprocServer32
- Microsoft: COM registry keys
- Microsoft: packaged and non-packaged desktop identity
Looking for a different code? Search another status or error code.
