| Previous | Next |
| MQ_ERROR_QUEUE_DELETED | MQ_ERROR_ILLEGAL_SORT_PROPID |
MQ_ERROR_ILLEGAL_CONTEXT
Why the exact HRESULT matters
Applications should keep MQ_ERROR_ILLEGAL_CONTEXT attached to the exact MSMQ call that produced it; translating it immediately to “queue error” discards the diagnostic boundary. Its diagnostic boundary is unsupported MQLocateBegin context parameter. The API requires the documented context form; legacy/non-null context data is rejected.
For MQ_ERROR_ILLEGAL_CONTEXT, the locator observes a directory snapshot beginning when MQLocateBegin is called. When diagnosing MQ_ERROR_ILLEGAL_CONTEXT, newly replicated objects and properties unsupported as columns or sort keys can produce results that differ from direct queue access.
When diagnosing MQ_ERROR_ILLEGAL_CONTEXT, public-queue discovery depends on both valid MSMQ query structures and AD DS behavior. In the MQ_ERROR_ILLEGAL_CONTEXT path, A malformed MQSORTSET should be separated from LDAP bind, schema, replication, or permissions failures.
Subsystem context
| Subsystem | MQLocateBegin directory queries over public-queue metadata |
|---|---|
| Decisive boundary | query restrictions, selected columns, and sort keys must be valid for the AD DS-backed locator |
| Code-specific focus | unsupported MQLocateBegin context parameter |
| Primary recovery rule | Pass the supported value and keep application paging state outside the MSMQ parameter. |
When diagnosing MQ_ERROR_ILLEGAL_CONTEXT, separate a malformed query structure from an AD DS availability error. In the MQ_ERROR_ILLEGAL_CONTEXT path, repeating the same invalid MQSORTSET or MQRESTRICTION against another domain controller will not repair it. For MQ_ERROR_ILLEGAL_CONTEXT, the code-specific boundary is unsupported MQLocateBegin context parameter.
Minimum useful telemetry
- The exact property used for filtering, projection, or ordering; associate it explicitly with
MQ_ERROR_ILLEGAL_CONTEXT. - When diagnosing
MQ_ERROR_ILLEGAL_CONTEXT, mqrestriction, mqcolumns, and mqsortset as submitted; capture the value before cleanup or retry changes it. - In the
MQ_ERROR_ILLEGAL_CONTEXTpath, the ad ds mode and domain identity of the caller; compare it with a known-good call using the same account and queue type. - For this
MQ_ERROR_ILLEGAL_CONTEXTresult, record the queue path or format name, local/remote placement, transactional flag, caller SID, process build, and UTC correlation ID when they apply.
For MQ_ERROR_ILLEGAL_CONTEXT, log certificate thumbprints, provider names, SIDs, GUIDs, lengths, and hashes where useful, but do not log private keys, symmetric keys, credentials, or confidential message bodies.
Step-by-step diagnosis
- Record the unsigned HRESULT,
MQ_ERROR_ILLEGAL_CONTEXT, and the native API or COM method before a framework replaces it with a generic exception. - When diagnosing
MQ_ERROR_ILLEGAL_CONTEXT, capture the AD DS mode and domain identity of the caller. - In the
MQ_ERROR_ILLEGAL_CONTEXTpath, capture the exact property used for filtering, projection, or ordering. - Reproduce with the smallest queue/message/property set that still returns
MQ_ERROR_ILLEGAL_CONTEXT; change one precondition at a time. - For
MQ_ERROR_ILLEGAL_CONTEXT, verify the postcondition after the failed call: queue existence, message presence, directory object state, transaction outcome, or generated output may differ by result. - When diagnosing
MQ_ERROR_ILLEGAL_CONTEXT, apply the code-specific recovery rule: Pass the supported value and keep application paging state outside the MSMQ parameter.
Retry and cleanup
Pass the supported value and keep application paging state outside the MSMQ parameter.
When diagnosing MQ_ERROR_ILLEGAL_CONTEXT, an immediate loop around the same call is not recovery. In the MQ_ERROR_ILLEGAL_CONTEXT path, define who owns cancellation, handle recreation, transaction reconciliation, and duplicate suppression before another attempt is issued.
Avoiding a false diagnosis
A directory query shape error is deterministic. For this MQ_ERROR_ILLEGAL_CONTEXT result, switching domain controllers cannot make an unsupported column, relation, or sort key valid. The specific focus for MQ_ERROR_ILLEGAL_CONTEXT remains unsupported MQLocateBegin context parameter.
- In the
MQ_ERROR_ILLEGAL_CONTEXTpath, A successful test under an interactive administrator account does not prove that the production service account has the same profile, token, directory access, or key permissions. - For this
MQ_ERROR_ILLEGAL_CONTEXTresult, restarting MSMQ before collecting evidence can invalidate handles and erase the first useful event; it is a containment action, not a root-cause diagnosis.
Example
An administration console encounters MQ_ERROR_ILLEGAL_CONTEXT. For MQ_ERROR_ILLEGAL_CONTEXT, it captures the restriction/column/sort structures and validates the query before testing directory availability. When diagnosing MQ_ERROR_ILLEGAL_CONTEXT, the acceptance test then changes only the decisive precondition and confirms both the HRESULT and the actual queue/message state.
A regression test should force MQ_ERROR_ILLEGAL_CONTEXT, assert the raw value and relevant outputs, then correct only the documented precondition and verify the intended success or neighboring HRESULT.
References
- Microsoft: MQLocateBegin — source used for the
MQ_ERROR_ILLEGAL_CONTEXTanalysis. - Microsoft Open Specifications: MSMQ and directory services — source used for the
MQ_ERROR_ILLEGAL_CONTEXTanalysis. - IETF RFC 4511: LDAP protocol — source used for the
MQ_ERROR_ILLEGAL_CONTEXTanalysis. - Microsoft: Message Queuing error and information codes — source used for the
MQ_ERROR_ILLEGAL_CONTEXTanalysis.
Looking for a different code? Search another status or error code.
