© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
20 replies
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()
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();
            }
            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.
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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

System.AccessViolationException
C#CC# / help
4y ago
System.AccessViolationException In windows but not in linux
C#CC# / help
2y ago
✅ Windows Audio Capture
C#CC# / help
2y ago