{"record":{"id":"81eb1849b671e9a0","repo":"NickeManarin/ScreenToGif","slug":"the-desktop-duplication-api-is-not-supported-on-th-81eb18","errorCode":null,"errorMessage":"The Desktop Duplication API is not supported on this screen.","messagePattern":"The Desktop Duplication API is not supported on this screen\\.","errorType":"exception","errorClass":"GraphicsConfigurationException","httpStatus":null,"severity":"error","filePath":"ScreenToGif/Capture/DirectImageCapture.cs","lineNumber":198,"sourceCode":"            //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>\n    /// Get the correct Output1 based on region to be captured.\n    /// </summary>\n    private Output1 GetOutput(Factory1 factory)\n    {\n        try\n        {\n            //Gets the output with the bigger area being intersected.\n            var output = factory.Adapters1.SelectMany(s => s.Outputs).FirstOrDefault(f => f.Description.DeviceName == DeviceName) ??","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/NickeManarin/ScreenToGif/blob/a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd/ScreenToGif/Capture/DirectImageCapture.cs#L180-L216","documentation":"Thrown by DirectImageCapture when DuplicateOutput raises a SharpDXException with the InvalidCall DXGI result code. Unlike the Unsupported case (which means the whole computer lacks DDA), InvalidCall typically means the specific output/device combination cannot be duplicated — often a multi-monitor or device-output mismatch issue.","triggerScenarios":"DuplicateOutput is called with a Device and Output1 that belong to different adapters, or the output is not the primary desktop output. Common with multi-GPU systems (integrated + discrete) where the device was created on one adapter but the output is on another.","commonSituations":"Laptop with hybrid graphics (Intel iGPU + NVIDIA dGPU) where ScreenToGif's DirectX device was created on adapter A but the target monitor is on adapter B. Monitor was disconnected or reconnected between enumeration and duplication. The selected output does not intersect the capture region.","solutions":["Ensure the Device and Output1 are created from the same adapter — enumerate adapters and match the output's adapter.","Re-enumerate outputs right before calling DuplicateOutput in case the monitor configuration changed.","On hybrid GPU systems, force the application to run on the integrated GPU (see the StackOverflow link in the source comment).","Handle GraphicsConfigurationException and fall back to BitBlt capture for the problematic output."],"exampleFix":"// before\ncatch (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\n// after: re-enumerate and match adapter before retrying\ncatch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.InvalidCall)\n{\n    Device = new SharpDX.Direct3D11.Device(output1.Adapter); // match adapter\n    DuplicatedOutput = output1.DuplicateOutput(Device);\n}","handlingStrategy":"validation","validationCode":"// Ensure Device and Output1 are from the same adapter\nvar output = factory.Adapters1\n    .SelectMany(a => a.Outputs)\n    .FirstOrDefault(o => o.Description.DeviceName == DeviceName);\nif (output == null || output.Adapter != Device.Adapter)\n    Device = new SharpDX.Direct3D11.Device(output.Adapter);","typeGuard":"static bool AreDeviceAndOutputSameAdapter(Device device, Output1 output)\n{\n    return device.Adapter.Description.Description == output.Adapter.Description.Description;\n}","tryCatchPattern":"try\n{\n    DuplicatedOutput = output1.DuplicateOutput(Device);\n}\ncatch (GraphicsConfigurationException ex) when (ex.Message.Contains(\"not supported on this screen\"))\n{\n    Device = new SharpDX.Direct3D11.Device(output1.Adapter);\n    DuplicatedOutput = output1.DuplicateOutput(Device);\n}","preventionTips":["On hybrid GPU systems, always create the Device from the same adapter as the target output.","Re-enumerate outputs before calling DuplicateOutput if the monitor configuration may have changed.","Log the adapter names for Device and Output when this error occurs to diagnose mismatches."],"tags":["dxgi","desktop-duplication","screen-capture","sharpdx","multi-gpu"],"backgroundTag":null,"analyzedSha":"a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd","analyzedAt":"2026-08-13T11:12:06.147Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}