{"record":{"id":"4af305889de13e7b","repo":"NickeManarin/ScreenToGif","slug":"could-not-find-the-specified-output-device","errorCode":null,"errorMessage":"Could not find the specified output device.","messagePattern":"Could not find the specified output device\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ScreenToGif/Capture/DirectImageCapture.cs","lineNumber":262,"sourceCode":"                    BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,\n                    CpuAccessFlags = CpuAccessFlags.None,\n                    Format = Format.B8G8R8A8_UNorm,\n                    Width = Height,\n                    Height = Width,\n                    OptionFlags = ResourceOptionFlags.None,\n                    MipLevels = 1,\n                    SampleDescription = new SampleDescription(1, 0),\n                    Usage = ResourceUsage.Default\n                });\n            }\n\n            //Create textures in here, after detecting the orientation?\n\n            return output.QueryInterface<Output1>();\n        }\n        catch (SharpDXException ex)\n        {\n            throw new Exception(\"Could not find the specified output device.\", ex);\n        }\n    }\n\n\n    public override int Capture(FrameInfo frame)\n    {\n        var res = new Result(-1);\n\n        try\n        {\n            //Try to get the duplicated output frame within given time.\n            res = DuplicatedOutput.TryAcquireNextFrame(0, out var info, out var resource);\n\n            if (FrameCount == 0 && (res.Failure || resource == null))\n            {\n                //Somehow, it was not possible to retrieve the resource, frame or metadata.\n                resource?.Dispose();\n                return FrameCount;","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/NickeManarin/ScreenToGif/blob/a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd/ScreenToGif/Capture/DirectImageCapture.cs#L244-L280","documentation":"The catch(SharpDXException) in GetOutput wraps any DirectX/DXGI failure raised while enumerating Adapters1/Outputs or calling output.QueryInterface<Output1>(). Unlike error 20 (no output found at all), this fires when DXGI itself throws — the adapter or output exists structurally but the call into it failed.","triggerScenarios":"output.QueryInterface<Output1>() raises a SharpDXException (e.g. DXGI_ERROR_DEVICE_REMOVED, access denied, driver-recreated swap chain), or enumerating factory.Adapters1/Outputs throws because the DXGI device was torn down.","commonSituations":"GPU driver crashed or was reset during enumeration (TDR / device-removed); the display adapter was disabled while the recorder was starting; running under a WDDM reset; security software blocking DXGI access; hybrid-GPU switching mid-call.","solutions":["Restart the recorder after the GPU driver stabilises; this is usually transient after a TDR.","Update the GPU driver to the latest vendor release (Intel/NVIDIA/AMD).","If it reproduces persistently, switch off 'Use Desktop Duplication API' to use BitBlt capture instead.","Check the inner SharpDXException.Descriptor.NativeApiCode in logs to identify the exact DXGI error and act on it."],"exampleFix":"// before\ncatch (SharpDXException ex)\n{\n    throw new Exception(\"Could not find the specified output device.\", ex);\n}\n\n// after\ncatch (SharpDXException ex) when (ex.ResultCode == SharpDX.DXGI.ResultCode.DeviceRemoved)\n{\n    throw new GraphicsConfigurationException(\"GPU device was removed during output enumeration.\", ex);\n}\ncatch (SharpDXException ex)\n{\n    throw new Exception($\"Could not find the specified output device. {ex.Descriptor.NativeApiCode}\", ex);\n}","handlingStrategy":"try-catch","validationCode":"// Validate adapter health before enumeration\ntry\n{\n    using var factory = new Factory1();\n    var healthy = factory.Adapters1.All(a => a.Description.Description != null);\n    if (!healthy) { /* defer capture, retry after GPU reset */ }\n}\ncatch (SharpDXException) { /* GPU not ready */ }","typeGuard":"catch (SharpDXException ex) when (ex.ResultCode == SharpDX.DXGI.ResultCode.DeviceRemoved || ex.ResultCode == SharpDX.DXGI.ResultCode.DeviceHung) { /* TDR — retry once after delay */ }","tryCatchPattern":"try { return output.QueryInterface<Output1>(); }\ncatch (SharpDXException ex) when (ex.ResultCode == SharpDX.DXGI.ResultCode.DeviceRemoved)\n{\n    LogWriter.Log(ex, \"DXGI device removed during output enumeration\");\n    throw new GraphicsConfigurationException(\"GPU device removed. Restart the recorder.\", ex);\n}\ncatch (SharpDXException ex)\n{\n    throw new Exception($\"Could not find the specified output device. {ex.Descriptor.NativeApiCode}\", ex);\n}","preventionTips":["Keep GPU drivers current; TDRs are the most common source.","On device-removed, dispose the Factory and rebuild from scratch rather than reusing stale adapters.","Avoid toggling the display adapter while the recorder is active."],"tags":["dxgi","desktop-duplication","sharpdx","gpu","capture"],"backgroundTag":null,"analyzedSha":"a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd","analyzedAt":"2026-08-13T11:12:06.147Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}