{"record":{"id":"b2fbfdd72cf64718","repo":"NickeManarin/ScreenToGif","slug":"too-many-applications-using-the-desktop-duplicatio","errorCode":null,"errorMessage":"Too many applications using the Desktop Duplication API. Please close one of the applications and try again.","messagePattern":"Too many applications using the Desktop Duplication API\\. Please close one of the applications and try again\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ScreenToGif/Capture/DirectImageCapture.cs","lineNumber":190,"sourceCode":"            OptionFlags = ResourceOptionFlags.None,\n            MipLevels = 1,\n            SampleDescription = new SampleDescription(1, 0),\n            Usage = ResourceUsage.Default\n        });\n\n        using (var factory = new Factory1())\n        {\n            //Get the Output1 based on the current capture region position.\n            using (var output1 = GetOutput(factory))\n            {\n                try\n                {\n                    //Make sure to run with the integrated graphics adapter if using a Microsoft hybrid system. https://stackoverflow.com/a/54196789/1735672\n                    DuplicatedOutput = output1.DuplicateOutput(Device);\n                }\n                catch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.NotCurrentlyAvailable)\n                {\n                    throw new Exception(\"Too many applications using the Desktop Duplication API. Please close one of the applications and try again.\", e);\n                }\n                catch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.Unsupported)\n                {\n                    throw new GraphicsConfigurationException(\"The Desktop Duplication API is not supported on this computer.\", e);\n                }\n                catch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.InvalidCall)\n                {\n                    throw new GraphicsConfigurationException(\"The Desktop Duplication API is not supported on this screen.\", e);\n                }\n                catch (SharpDXException e) when (e.Descriptor.NativeApiCode == \"E_INVALIDARG\")\n                {\n                    throw new GraphicsConfigurationException(\"Looks like that the Desktop Duplication API is not supported on this screen.\", e);\n                }\n            }\n        }\n    }\n\n    /// <summary>","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/NickeManarin/ScreenToGif/blob/a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd/ScreenToGif/Capture/DirectImageCapture.cs#L172-L208","documentation":"Thrown by DirectImageCapture when output1.DuplicateOutput(Device) raises a SharpDXException with the NotCurrentlyAvailable DXGI result. The Desktop Duplication API (DDA) allows only one active duplication session per output at a time; a second attempt returns NotCurrentlyAvailable.","triggerScenarios":"DuplicateOutput is called while another process already holds a DDA session on the same monitor. Conflicting apps: other screen recorders (OBS, ShareX, Snagit), remote desktop software, or a previous ScreenToGif capture session that did not properly release its DuplicatedOutput.","commonSituations":"User has another screen recording tool running on the same monitor. ScreenToGif crashed or was force-closed without disposing the DuplicatedOutput, leaving a stale DDA session. Windows RDP session is active on the target output. Multiple instances of ScreenToGif are capturing the same screen.","solutions":["Close other screen recording applications that may be using DDA on the same monitor.","Restart ScreenToGif or the conflicting application to release the stale DDA session.","Ensure DuplicatedOutput is properly disposed (Dispose pattern) when capture stops.","Switch to a different capture method (e.g., GDI-based) as a fallback when DDA is unavailable."],"exampleFix":"// before\ncatch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.NotCurrentlyAvailable)\n{\n    throw new Exception(\"Too many applications using the Desktop Duplication API. Please close one of the applications and try again.\", e);\n}\n\n// after: retry once after a brief delay, then throw if still unavailable\ncatch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.NotCurrentlyAvailable)\n{\n    DuplicatedOutput?.Dispose();\n    await Task.Delay(500);\n    try { DuplicatedOutput = output1.DuplicateOutput(Device); }\n    catch { throw new Exception(\"Too many applications using the Desktop Duplication API...\", e); }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    InitializeDesktopDuplication();\n}\ncatch (Exception ex) when (ex.Message.Contains(\"Too many applications\"))\n{\n    // Prompt user to close conflicting apps or fall back to BitBlt\n    CaptureMode = CaptureMode.BitBlt;\n}","preventionTips":["Ensure DuplicatedOutput is disposed when capture stops to prevent stale DDA sessions.","Detect if another screen recorder is running before attempting DDA.","Implement a fallback to BitBlt capture when DDA is unavailable."],"tags":["dxgi","desktop-duplication","screen-capture","sharpdx","windows-api"],"backgroundTag":null,"analyzedSha":"a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd","analyzedAt":"2026-08-13T11:12:06.147Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}