| Previous | Next |
| E_STRING_NOT_NULL_TERMINATED | E_ASYNC_OPERATION_NOT_STARTED |
E_ILLEGAL_DELEGATE_ASSIGNMENT
Delegate assignment is not allowed in this context
E_ILLEGAL_DELEGATE_ASSIGNMENT is HRESULT 2147483672 (0x80000018) from winerror.h. The documented description is “A delegate was assigned when not allowed.” The relevant context is the Windows Runtime metadata, object lifetime, asynchronous operation, activation, and apartment model.
What to verify
Verify that the delegate ownership model, token-based subscription rules, and current lifecycle state are known. That boundary prevents this result from being misclassified as corruption, network failure, or a reason for an unsafe automatic retry.
Where it is encountered
- This result can be returned during C++/WinRT, WRL, .NET projections, or native WinRT ABI calls.
- This result can be returned during runtime-class activation, WinMD reflection, asynchronous objects, observable state, or view lifecycle.
- It can be returned during cross-thread and cross-apartment handoff between UI, ASTA, STA, MTA, broker, and background work.
The immediate focus is an event, callback slot, or runtime property whose contract rejects replacement, duplication, or assignment after a lifecycle boundary.
Correct handling and recovery
Use the documented add/remove event pattern or assign only during the permitted initialization phase. Revoke stale handlers during teardown.
Reconcile partial output and server-side effects before attempting the operation again.
Difference from nearby HRESULTs
It rejects the callback binding itself; E_ILLEGAL_METHOD_CALL can reject any method because of timing.
Practical scenario
A component attempts to overwrite a framework-owned completion delegate after startup. It changes to event-token subscription and revokes the token when the view closes.
References
Looking for a different code? Search another status or error code.