{"record":{"id":"770c6760744cf996","repo":"HandyOrg/HandyControl","slug":"specified-cast-is-not-valid","errorCode":null,"errorMessage":"Specified cast is not valid.","messagePattern":"Specified cast is not valid\\.","errorType":"exception","errorClass":"ObjectDisposedException","httpStatus":null,"severity":"error","filePath":"src/Shared/HandyControl_Shared/Data/DisposableObject.cs","lineNumber":37,"sourceCode":"        Dispose(false);\n    }\n\n    public event EventHandler Disposing\n    {\n        add\n        {\n            ThrowIfDisposed();\n            _disposing += value;\n        }\n        remove\n        {\n            _disposing -= value;\n        }\n    }\n\n    protected void ThrowIfDisposed()\n    {\n        if (IsDisposed) throw new ObjectDisposedException(GetType().Name);\n    }\n\n    protected void Dispose(bool disposing)\n    {\n        if (IsDisposed) return;\n\n        try\n        {\n            if (disposing)\n            {\n                _disposing?.Invoke(this, EventArgs.Empty);\n                _disposing = null;\n                DisposeManagedResources();\n            }\n\n            DisposeNativeResources();\n        }\n        finally","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/HandyControl_Shared/Data/DisposableObject.cs#L19-L55","documentation":"InvalidCastException ('Specified cast is not valid.') raised in DisposableObject's disposal path (ThrowIfDisposed/Dispose): an object retrieved during disposing — typically from the disposed-event or resource cleanup — is not the type it is cast to. The generic message indicates the runtime type of a value did not match the target cast inside this disposed-object plumbing.","triggerScenarios":"Thrown at src/Shared/HandyControl_Shared/Data/DisposableObject.cs:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use 'is' pattern matching or 'as' with a null check instead of a hard cast","Verify the actual runtime type (GetType/inspect) before casting in Dispose overrides","Ensure generic/base disposable state stores consistent types across derived classes"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}