{"record":{"id":"c9da39f1eeddad6c","repo":"unoplatform/uno","slug":"the-current-dragdropextension-does-not-match-the-p","errorCode":null,"errorMessage":"The current DragDropExtension does not match the provided args","messagePattern":"The current DragDropExtension does not match the provided args","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Uno.UI/ts/Windows/ApplicationModel/DataTransfer/DragAndDropExtension.ts","lineNumber":36,"sourceCode":"\t\t\t\tif ((<any>globalThis).DotnetExports !== undefined) {\n\t\t\t\t\tDragDropExtension._dispatchDropEventMethod = (<any>globalThis).DotnetExports.UnoUI.Windows.ApplicationModel.DataTransfer.DragDrop.Core.DragDropExtension.OnNativeDropEvent;\n\t\t\t\t} else {\n\t\t\t\t\tthrow `DragDropExtension: Unable to find dotnet exports`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (DragDropExtension._current) {\n\t\t\t\tthrow new Error(\"A DragDropExtension has already been enabled\");\n\t\t\t}\n\n\t\t\tDragDropExtension._dispatchDragDropArgs = pArgs;\n\t\t\tDragDropExtension._nextDropId = 1;\n\t\t\tDragDropExtension._current = new DragDropExtension();\n\t\t}\n\n\t\tpublic static disable(pArgs: number): void {\n\t\t\tif (DragDropExtension._dispatchDragDropArgs != pArgs) {\n\t\t\t\tthrow new Error(\"The current DragDropExtension does not match the provided args\");\n\t\t\t}\n\t\t\t\n\t\t\tDragDropExtension._current.dispose();\n\t\t\tDragDropExtension._current = null;\n\t\t\tDragDropExtension._dispatchDragDropArgs = null;\n\t\t}\n\n\t\tconstructor() {\n\t\t\t// Events fired on the drop target\n\t\t\t// Note: dragenter and dragover events will enable drop on the app\n\t\t\tthis._dropHandler = this.dispatchDropEvent.bind(this);\n\t\t\tdocument.addEventListener(\"dragenter\", this._dropHandler);\n\t\t\tdocument.addEventListener(\"dragover\", this._dropHandler);\n\t\t\tdocument.addEventListener(\"dragleave\", this._dropHandler); // Seems to be raised also on drop?\n\t\t\tdocument.addEventListener(\"drop\", this._dropHandler);\n\n\t\t\t// Events fired on the draggable target (the source element)\n\t\t\t//this._dragHandler = this.dispatchDragEvent.bind(this);","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/Uno.UI/ts/Windows/ApplicationModel/DataTransfer/DragAndDropExtension.ts#L18-L54","documentation":"Thrown by DragDropExtension.disable when the provided pArgs does not match the _dispatchDropArgs stored during enable. This guard prevents one consumer from disabling a DragDropExtension that was enabled by a different consumer (mismatched enable/disable pairs).","triggerScenarios":"disable is called with a pArgs pointer different from the one passed to the preceding enable, or disable is called when enable was never invoked (so _dispatchDropArgs is null and pArgs is a non-null pointer).","commonSituations":"Two different drop targets each with their own args calling disable on the shared singleton; a stale args handle from a disposed managed object; calling disable after the extension was already disabled by another path.","solutions":["Pass the exact same pArgs value to disable that was passed to enable — store it and reuse it.","Ensure enable/disable calls are balanced per consumer; do not let consumer A disable consumer B's extension."],"exampleFix":"// before: mismatched args\nDragDropExtension.enable(argsA);\nDragDropExtension.disable(argsB); // argsA !== argsB → throws\n\n// after: balanced pair\nDragDropExtension.enable(argsA);\nDragDropExtension.disable(argsA); // matches","handlingStrategy":"validation","validationCode":"// Ensure args match before disabling\nif ((<any>DragDropExtension)._dispatchDragDropArgs === pArgs) {\n    DragDropExtension.disable(pArgs);\n}","typeGuard":null,"tryCatchPattern":"try {\n    DragDropExtension.disable(pArgs);\n} catch (e) {\n    if (e.message.includes('does not match')) {\n        // args mismatch — log and reconcile state\n    } else { throw e; }\n}","preventionTips":["Store the pArgs from enable and pass the exact same value to disable.","Never let one consumer disable another consumer's extension.","Log enable/disable args pairs to detect mismatches during debugging."],"tags":["wasm","drag-and-drop","lifecycle","validation","typescript"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}