Closed dotnetdan closed 2 years ago
You need to keep the references to the objects to keep them alive. It's working for a few seconds because the garbage collector hasn't kicked in yet.
Make the GraphicsCaptureSession and Direct3D11CaptureFramePool member variables and that should solve your problem.
The fail fast itself is a different issue in that build, where a COM proxy is being poked on the wrong thread (perhaps the finalizer thread). I would make sure you call Dispose on both objects from the thread that created them when you're finished.
That did the trick, thank you!
Using .NET 6 & AvaloniaUI on Windows 10.0.19041, I'm attempting to capture frames from another application's hwnd. My capture session runs for about 15 seconds before suddenly terminating and creating a WER. The exception code is 0xc0000409 which is a fail fast exception:
This is how I am creating my capture session. The Direct3D helper methods are from the WPF sample, I only modified it to use the new COM marshaling API's starting in .net 5.
!analyze -v in WinDbg shows: