unoplatform/uno · error · Error
A DragDropExtension has already been enabled
Error message
A DragDropExtension has already been enabled
What it means
Thrown by DragDropExtension.enable when the static _current field is already non-null, meaning a DragDropExtension instance is already active. This is a singleton-enforcement guard: only one drag-drop extension can own the DOM event listeners at a time.
Source
Thrown at src/Uno.UI/ts/Windows/ApplicationModel/DataTransfer/DragAndDropExtension.ts:26
private static _current: DragDropExtension;
private static _nextDropId: number;
private _dropHandler: any;
private _pendingDropId: number;
private _pendingDropData: DataTransfer;
public static enable(pArgs: number): void {
if (!DragDropExtension._dispatchDropEventMethod) {
if ((<any>globalThis).DotnetExports !== undefined) {
DragDropExtension._dispatchDropEventMethod = (<any>globalThis).DotnetExports.UnoUI.Windows.ApplicationModel.DataTransfer.DragDrop.Core.DragDropExtension.OnNativeDropEvent;
} else {
throw `DragDropExtension: Unable to find dotnet exports`;
}
}
if (DragDropExtension._current) {
throw new Error("A DragDropExtension has already been enabled");
}
DragDropExtension._dispatchDragDropArgs = pArgs;
DragDropExtension._nextDropId = 1;
DragDropExtension._current = new DragDropExtension();
}
public static disable(pArgs: number): void {
if (DragDropExtension._dispatchDragDropArgs != pArgs) {
throw new Error("The current DragDropExtension does not match the provided args");
}
DragDropExtension._current.dispose();
DragDropExtension._current = null;
DragDropExtension._dispatchDragDropArgs = null;
}
constructor() {View on GitHub (pinned to 0418340488)
Solutions
- Call disable(pArgs) to tear down the previous DragDropExtension before calling enable again.
- Ensure only one DragDropExtension is enabled at a time in the WASM app; share a single extension across drop targets.
- Verify that the previous enable/disable lifecycle completed (disable sets _current = null) before re-enabling.
Example fix
// before: enable called twice → throws on second DragDropExtension.enable(args1); DragDropExtension.enable(args2); // _current already set // after: disable first DragDropExtension.enable(args1); // ... use it ... DragDropExtension.disable(args1); DragDropExtension.enable(args2);
Defensive patterns
Strategy: validation
Validate before calling
// Check if an extension is already active before enabling
if (!(<any>DragDropExtension)._current) {
DragDropExtension.enable(pArgs);
} else {
// already enabled — disable first or skip
} Try / catch
try {
DragDropExtension.enable(pArgs);
} catch (e) {
if (e.message === 'A DragDropExtension has already been enabled') {
DragDropExtension.disable(existingArgs);
DragDropExtension.enable(pArgs);
} else { throw e; }
} Prevention
- Always balance enable/disable calls; track the active args.
- Share a single DragDropExtension across multiple drop targets instead of enabling per-target.
- Disable the extension in the managed Unloaded/dispose path.
When it happens
Trigger: C# calls enable() twice without a matching disable() in between — e.g. two UI elements both registered a DragDropExtension, or enable was called from overlapping async paths without proper disable.
Common situations: Multiple DropBox/ListView controls each initializing their own DragDropExtension; a re-enable without disable after a page navigation or visual-tree rebuild; a race where enable is called concurrently.
Related errors
- The current DragDropExtension does not match the provided ar
- No pending drag and drop data.
- retrieveFiles failed to find pending drag and drop data for
- Item ${guid} is a directory handle. You cannot use it as a F
- The staged content was released when the download was trigge
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/197bee2e760f0b95.
Report an issue: GitHub.