{"record":{"id":"cd76c2239e556a88","repo":"NickeManarin/ScreenToGif","slug":"directshow-samplegrabber-not-installed-registered","errorCode":null,"errorMessage":"DirectShow SampleGrabber not installed/registered!","messagePattern":"DirectShow SampleGrabber not installed/registered!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"ScreenToGif/Webcam/DirectX/CaptureWebcam.cs","lineNumber":260,"sourceCode":"        {\n            //Make a new filter graph.\n            GraphBuilder = (ExtendStreaming.IGraphBuilder)Activator.CreateInstance(Type.GetTypeFromCLSID(Uuid.Clsid.FilterGraph, true));\n\n            //Get the Capture Graph Builder.\n            var clsid = Uuid.Clsid.CaptureGraphBuilder2;\n            var riid = typeof(ExtendStreaming.ICaptureGraphBuilder2).GUID;\n            CaptureGraphBuilder = (ExtendStreaming.ICaptureGraphBuilder2)Activator.CreateInstance(Type.GetTypeFromCLSID(clsid, true));\n\n            //Link the CaptureGraphBuilder to the filter graph\n            var hr = CaptureGraphBuilder.SetFiltergraph(GraphBuilder);\n\n            if (hr < 0)\n                Marshal.ThrowExceptionForHR(hr);\n\n            var comType = Type.GetTypeFromCLSID(Uuid.Clsid.SampleGrabber);\n\n            if (comType == null)\n                throw new Exception(\"DirectShow SampleGrabber not installed/registered!\");\n\n            var comObj = Activator.CreateInstance(comType);\n            SampGrabber = (EditStreaming.ISampleGrabber)comObj; comObj = null;\n\n            _baseGrabFlt = (CoreStreaming.IBaseFilter) SampGrabber;\n\n            var media = new CoreStreaming.AmMediaType();\n\n            //Get the video device and add it to the filter graph\n            if (VideoDevice != null)\n            {\n                VideoDeviceFilter = (CoreStreaming.IBaseFilter)Marshal.BindToMoniker(VideoDevice.MonikerString);\n\n                hr = GraphBuilder.AddFilter(VideoDeviceFilter, \"Video Capture Device\");\n\n                if (hr < 0)\n                    Marshal.ThrowExceptionForHR(hr);\n","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/NickeManarin/ScreenToGif/blob/a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd/ScreenToGif/Webcam/DirectX/CaptureWebcam.cs#L242-L278","documentation":"CaptureWebcam.CreateGraph needs the DirectShow SampleGrabber COM filter. It calls Type.GetTypeFromCLSID(Uuid.Clsid.SampleGrabber); if that returns null (the COM class is not registered), it throws. The SampleGrabber lives in qedit.dll and is part of the legacy DirectShow runtime.","triggerScenarios":"Selecting a webcam device when qedit.dll (which registers the SampleGrabber CLSID) is missing or unregistered on the machine.","commonSituations":"Windows N / KN editions without the Media Feature Pack; Windows Server without Desktop Experience / Media Foundation; qedit.dll removed or unregistered by a cleanup tool; older qedit.dll never registered on a stripped Windows image.","solutions":["Install the Media Feature Pack (N/KN editions) or enable the Desktop Experience / Media Foundation feature on Server.","Re-register qedit.dll: run `regsvr32 %SystemRoot%\\System32\\qedit.dll` from an elevated prompt.","Run `sfc /scannow` to restore missing system binaries.","If webcam capture is optional, disable the webcam feature until the runtime is repaired."],"exampleFix":"// before\nvar comType = Type.GetTypeFromCLSID(Uuid.Clsid.SampleGrabber);\nif (comType == null)\n    throw new Exception(\"DirectShow SampleGrabber not installed/registered!\");\n\n// after\nvar comType = Type.GetTypeFromCLSID(Uuid.Clsid.SampleGrabber);\nif (comType == null)\n    throw new Exception(\"DirectShow SampleGrabber not installed/registered. Install the Media Feature Pack (N editions) or run: regsvr32 %SystemRoot%\\\\System32\\\\qedit.dll\");","handlingStrategy":"validation","validationCode":"var comType = Type.GetTypeFromCLSID(Uuid.Clsid.SampleGrabber);\nif (comType == null)\n    // surface a user message: install Media Feature Pack or run regsvr32 qedit.dll\nreturn comType != null;","typeGuard":"static bool IsSampleGrabberRegistered => Type.GetTypeFromCLSID(Uuid.Clsid.SampleGrabber) != null;","tryCatchPattern":"try { CreateGraph(); }\ncatch (Exception ex) when (ex.Message.Contains(\"SampleGrabber\"))\n{ /* instruct user to install Media Feature Pack / register qedit.dll */ }","preventionTips":["Detect N/KN editions at install time and prompt for the Media Feature Pack.","Run `regsvr32 %SystemRoot%\\System32\\qedit.dll` from an installer step on Server SKUs.","Gate the webcam feature behind IsSampleGrabberRegistered."],"tags":["directshow","webcam","com","missing-dependency","windows"],"backgroundTag":null,"analyzedSha":"a4d0a67c2131cd048ceec86cd40afc2f1a06f2fd","analyzedAt":"2026-08-13T11:12:06.147Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}