C#C
C#3y ago
CoRoys

❔ System.AccessViolationException from Windows.Media.Audio.AudioPlaybackConnection (UWP)

For familiarity, AudioPlaybackConnection on UWP enables an A2DP sink Bluetooth profile connection between Windows and another device (for receiving audio playback). Following https://learn.microsoft.com/en-us/windows/uwp/audio-video-camera/enable-remote-audio-playback, the app crashes on TryCreateFromId():
            ConnectionInfo = $"Connecting to {CurrentDevice?.Name ?? "selected device"}...";
            
            try
            {
                using var connection = AudioPlaybackConnection.TryCreateFromId(device.DeviceInformation.Id);

                await connection.OpenAsync();

                ConnectionInfo = $"▷ Connected to {CurrentDevice?.Name ?? "device"}";
            }
            catch (Exception x)
            {
                _ = await ShowDialogueAsync($"An error occurred while trying to open a connection:\n\n\n{x}", "Error");
                Disconnect();
            }

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


As seen in the screenshot attached, this exception is a ghost. Does anyone have any idea how to debug this?
image.png
Was this page helpful?