diff --git a/SightKeeper.Application.Windows/DX11ScreenCapture.cs b/SightKeeper.Application.Windows/DX11ScreenCapture.cs index 2505c120..e595a9fb 100644 --- a/SightKeeper.Application.Windows/DX11ScreenCapture.cs +++ b/SightKeeper.Application.Windows/DX11ScreenCapture.cs @@ -54,9 +54,12 @@ public DX11ScreenCapture() private unsafe ReadOnlySpan2D Capture() { - _device.ImmediateContext.UnmapSubresource(_screenTexture, 0); - _screenResource?.Dispose(); - _outputDuplication.ReleaseFrame(); + if (_screenResource != null) + { + _device.ImmediateContext.UnmapSubresource(_screenTexture, 0); + _screenResource.Dispose(); + _outputDuplication.ReleaseFrame(); + } _outputDuplication.TryAcquireNextFrame(1000, out _, out _screenResource).CheckError(); using (var screenTexture2D = _screenResource.QueryInterface()) _device.ImmediateContext.CopyResource(screenTexture2D, _screenTexture);