| Previous | Next |
| TYPE_E_CIRCULARTYPE | STG_E_FILENOTFOUND |
STG_E_INVALIDFUNCTION
Requested structured-storage operation is not valid
STG_E_INVALIDFUNCTION is HRESULT 2147680257 (0x80030001) from winerror.h. AllStat describes it as “Unable to perform requested operation.” The result belongs to an IStorage, IStream, ILockBytes, or file-backed storage method. For STG_E_INVALIDFUNCTION, the important boundary is not merely failure but which object and state transition established: the selected operation is not supported by that object, storage mode, or implementation.
The decisive meaning of STG_E_INVALIDFUNCTION is that the selected operation is not supported by that object, storage mode, or implementation. For STG_E_INVALIDFUNCTION, the severity bit does not decide handling; the controlling fact is that the selected operation is not supported by that object, storage mode, or implementation. Interpret STG_E_INVALIDFUNCTION at the native boundary before a wrapper hides the condition that the selected operation is not supported by that object, storage mode, or implementation.
Where the result appears
STG_E_INVALIDFUNCTIONcan surface in a IStorage, IStream, ILockBytes, property storage, compound-file parsing, or persistence code.- For
STG_E_INVALIDFUNCTION, map the failure to one concrete operation among StgOpenStorage, StgCreateStorageEx, IStorage, IStream, IPropertyStorage, STATSTG, and the selected STGM mode. - Preserve storage path or identity, STGM mode, stream or storage name, transaction generation, file hash, and backing provider before releasing or replacing the object that returned
STG_E_INVALIDFUNCTION.
An incident record for STG_E_INVALIDFUNCTION must distinguish caller, runtime, provider, and backing resource while testing whether the selected operation is not supported by that object, storage mode, or implementation.
Typical causes and interpretation boundary
The immediate contract boundary is specific: the selected operation is not supported by that object, storage mode, or implementation. Common cause branches include the following:
- A method is called on the wrong storage abstraction.
- The backing provider deliberately omits the operation.
- The object was opened with a mode that makes the requested function unavailable.
For STG_E_INVALIDFUNCTION, confirm the cause branch that explains why the selected operation is not supported by that object, storage mode, or implementation by using call arguments, object state, metadata, device information, or provider traces.
Evidence and telemetry
- Record
STG_E_INVALIDFUNCTION, 0x80030001, the native method name, process and thread IDs, operation ID, component build, architecture, and elapsed time. - For
STG_E_INVALIDFUNCTION, capture stream names, offsets, lengths, transaction state, backing path, and the validity of partially written output. - Keep any IErrorInfo, provider extended status, storage or device event, and the first lower-level failure that preceded
STG_E_INVALIDFUNCTION. - Correlate STG_E_INVALIDFUNCTION with process and thread identity, component versions, architecture, and the package owning an IStorage, IStream, ILockBytes, or file-backed storage method.
- When handling
STG_E_INVALIDFUNCTION, release interfaces in child-before-parent order, close native handles once, and do not commit or replace output whose validity is uncertain.
Telemetry for STG_E_INVALIDFUNCTION should retain structural facts that prove the selected operation is not supported by that object, storage mode, or implementation, while excluding content, credentials, firmware bytes, CSS keys, and personal data.
Diagnostic sequence
- Capture
STG_E_INVALIDFUNCTIONat the native boundary before a framework converts it to a generic exception. - For
STG_E_INVALIDFUNCTION, identify the exact object generation and method among StgOpenStorage, StgCreateStorageEx, IStorage, IStream, IPropertyStorage, STATSTG, and the selected STGM mode. - Prove the decisive condition: the selected operation is not supported by that object, storage mode, or implementation.
- Test the likely causes independently: a method is called on the wrong storage abstraction; the backing provider deliberately omits the operation; the object was opened with a mode that makes the requested function unavailable.
- Before cleanup after
STG_E_INVALIDFUNCTION, classify each output as valid, unchanged, partial, or ownership-transferred. - For
STG_E_INVALIDFUNCTION, change one cause candidate at a time—a method is called on the wrong storage abstraction; the backing provider deliberately omits the operation; the object was opened with a mode that makes the requested function unavailable—and reproduce with a minimal fixture.
Correct handling and recovery
For STG_E_INVALIDFUNCTION, the primary recovery is to select a supported interface or mode and branch on capability instead of retrying the same method. The STG_E_INVALIDFUNCTION failure report should expose enough an IStorage, IStream, ILockBytes, or file-backed storage method state to understand why the selected operation is not supported by that object, storage mode, or implementation without a production debugger.
Retry STG_E_INVALIDFUNCTION only when evidence shows the state behind “the selected operation is not supported by that object, storage mode, or implementation” can change and the operation is repeatable. Reconcile persistent, remote, device, or ownership state before repeating STG_E_INVALIDFUNCTION.
Practical scenario
A component asks a read-only package stream to resize itself; the provider rejects the operation because resizing is not valid for that stream. Record the decisive state for STG_E_INVALIDFUNCTION and verify recovery on a fresh object or request generation.
Difference from related HRESULTs
STG_E_UNIMPLEMENTEDFUNCTION says the function is not implemented; STG_E_INVALIDFUNCTION can also mean that the function is inappropriate for this object Tests and telemetry should preserve that boundary for STG_E_INVALIDFUNCTION.
Developer and administrator guidance
Developers handling STG_E_INVALIDFUNCTION should make object lifetime and state transitions explicit, preserve the native HRESULT, and keep cleanup paths safe when initialization or output is partial. For STG_E_INVALIDFUNCTION, exercise direct and transacted modes, read-only and writable paths, cancellation, malformed input, and cleanup after partial output.
For STG_E_INVALIDFUNCTION, administrators should repair the component owning an IStorage, IStream, ILockBytes, or file-backed storage method as a versioned unit instead of copying arbitrary DLLs. Repair for STG_E_INVALIDFUNCTION should target only the evidence-backed component, provider, document, device, or configuration.
References
- Microsoft: COM error codes for STG and RPC — official Microsoft documentation relevant to
STG_E_INVALIDFUNCTION. - Microsoft: Structured Storage — official Microsoft documentation relevant to
STG_E_INVALIDFUNCTION. - Microsoft: IStorage — official Microsoft documentation relevant to
STG_E_INVALIDFUNCTION. - Microsoft: IStream — official Microsoft documentation relevant to
STG_E_INVALIDFUNCTION.
Looking for a different code? Search another status or error code.