NickeManarin/ScreenToGif · error · GraphicsConfigurationException

Looks like that the Desktop Duplication API is not supported

Error message

Looks like that the Desktop Duplication API is not supported on this screen.

What it means

Thrown by DirectImageCapture when DuplicateOutput raises a SharpDXException whose Descriptor.NativeApiCode is 'E_INVALIDARG'. This is a low-level COM/DXGI error indicating an invalid argument was passed to the duplication call — functionally similar to the InvalidCall case but surfaced through a different error code path.

Source

Thrown at ScreenToGif/Capture/DirectImageCapture.cs:202

                {
                    //Make sure to run with the integrated graphics adapter if using a Microsoft hybrid system. https://stackoverflow.com/a/54196789/1735672
                    DuplicatedOutput = output1.DuplicateOutput(Device);
                }
                catch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.NotCurrentlyAvailable)
                {
                    throw new Exception("Too many applications using the Desktop Duplication API. Please close one of the applications and try again.", e);
                }
                catch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.Unsupported)
                {
                    throw new GraphicsConfigurationException("The Desktop Duplication API is not supported on this computer.", e);
                }
                catch (SharpDXException e) when (e.Descriptor == SharpDX.DXGI.ResultCode.InvalidCall)
                {
                    throw new GraphicsConfigurationException("The Desktop Duplication API is not supported on this screen.", e);
                }
                catch (SharpDXException e) when (e.Descriptor.NativeApiCode == "E_INVALIDARG")
                {
                    throw new GraphicsConfigurationException("Looks like that the Desktop Duplication API is not supported on this screen.", e);
                }
            }
        }
    }

    /// <summary>
    /// Get the correct Output1 based on region to be captured.
    /// </summary>
    private Output1 GetOutput(Factory1 factory)
    {
        try
        {
            //Gets the output with the bigger area being intersected.
            var output = factory.Adapters1.SelectMany(s => s.Outputs).FirstOrDefault(f => f.Description.DeviceName == DeviceName) ??
                         factory.Adapters1.SelectMany(s => s.Outputs).OrderByDescending(f =>
                         {
                             var x = Math.Max(Left, f.Description.DesktopBounds.Left);
                             var num1 = Math.Min(Left + Width, f.Description.DesktopBounds.Right);

View on GitHub (pinned to a4d0a67c21)

Solutions

  1. Ensure Device and Output1 are from the same adapter — verify with output1.Adapter.Description matches the device's adapter.
  2. Re-create the Device from the correct adapter before calling DuplicateOutput.
  3. Update graphics drivers to ensure DXGI error codes are mapped correctly.
  4. Fall back to BitBlt capture when DDA fails with E_INVALIDARG.

Example fix

// before
catch (SharpDXException e) when (e.Descriptor.NativeApiCode == "E_INVALIDARG")
{
    throw new GraphicsConfigurationException("Looks like that the Desktop Duplication API is not supported on this screen.", e);
}

// after: log adapter mismatch details for diagnosis
catch (SharpDXException e) when (e.Descriptor.NativeApiCode == "E_INVALIDARG")
{
    LogWriter.Log($"DDA E_INVALIDARG: Device adapter={Device.Adapter.Description.Description}, Output adapter={output1.Adapter.Description.Description}");
    throw new GraphicsConfigurationException("The Desktop Duplication API is not supported on this screen (adapter mismatch).", e);
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify adapter match before DuplicateOutput
if (Device.Adapter.Interface.Parent != output1.Adapter.Interface.Parent)
{
    Device.Dispose();
    Device = new SharpDX.Direct3D11.Device(output1.Adapter);
}

Type guard

static bool AreAdaptersCompatible(Device device, Output1 output)
{
    return device.Adapter.Description.Description == output.Adapter.Description.Description;
}

Try / catch

try
{
    DuplicatedOutput = output1.DuplicateOutput(Device);
}
catch (GraphicsConfigurationException ex) when (ex.InnerException is SharpDXException sde
    && sde.Descriptor.NativeApiCode == "E_INVALIDARG")
{
    Device = new SharpDX.Direct3D11.Device(output1.Adapter);
    DuplicatedOutput = output1.DuplicateOutput(Device);
}

Prevention

When it happens

Trigger: DuplicateOutput receives a Device or Output1 argument that DXGI rejects at the native level. This can happen with mismatched device/output adapters, a null or disposed Device, or an output that was invalidated between enumeration and the duplication call.

Common situations: Same root causes as error [18]: hybrid GPU mismatch, monitor disconnected/reconnected, device created on wrong adapter. The NativeApiCode 'E_INVALIDARG' is the raw HRESULT form of the error, suggesting an older driver or a DXGI version that maps the failure to this code rather than InvalidCall.

Related errors


AI-assisted analysis of NickeManarin/ScreenToGif@a4d0a67c21 (2026-08-13). Data as JSON: /api/errors/73a3b0f190f7660f. Report an issue: GitHub.