mediaCapture.CameraStreamState occasionally throws InvalidCastException

Hong 1,051 Reputation points
2021-06-09T02:00:17.18+00:00

mediaCapture.CameraStreamState usually works fine, but occasionally it throws the following:

Exception: Unable to cast object of type 'EETypeRva:0x0006C288(Windows.Media.Capture.MediaCapture)' to type 'EETypeRva:0x0006C338'.
Type: System.InvalidCastException
Stack trace:
at System.Runtime.InteropServices.McgMarshal.GetInterface(__ComObject, RuntimeTypeHandle) + 0x112
at __Interop.ComCallHelpers.Call(__ComObject, RuntimeTypeHandle, Int32, Void*) + 0x3a
at __Interop.ForwardComStubs.Stub_63TThis + 0x31
at Windows.Media.Capture.MediaCapture.get_CameraStreamState() + 0x18

Could anyone shed some light on the possible causes?

Universal Windows Platform (UWP)
{count} votes