Winforms Project Crashes When Setting URL of axWindowsMediaPlayer Object - Code 3221225477 (0xc0000005) 'Access violation'

Atlerius Omega 1 Reputation point
2022-07-29T18:08:06.177+00:00

I'm having an issue with a C# Windows Forms project I'm working on in Visual Studio 2022. I have a Windows Media Player object (axWindowsMediaPlayer) and whenever I set the URL to the path to a video file on disk, the program crashes with code 3221225477 (0xc0000005) 'Access violation'. This is the line that causes the crash:

axWindowsMediaPlayer2.URL = @"C:\2022-06-22 17-01-45.mp4";  

I've made a bare-bones project just to test this and still see the same behavior. It's just a single window with a Windows Media Player widget and a single button that sets the URL. Whenever I click the button to set the URL it crashes. If I set the URL in the Properties window instead of during runtime, nothing at all happens. It doesn't cause a crash but it also doesn't set the file. If I try to play the file (when set through Properties) using Ctlcontrol.play() nothing happens.

I've tried different files in different locations on disk including inside the project directory, I have updated Windows, I've repaired, and uninstalled and re-installed Visual Studio. Nothing has had any effect.

This is a total blocker for me so any help would be greatly appreciated.

Developer technologies | Windows Forms
{count} votes

1 answer

Sort by: Most helpful
  1. Atlerius Omega 1 Reputation point
    2022-08-01T20:23:06.11+00:00

    OK I have found the root cause and a good workaround.

    The crash is caused by the external Quadro graphics card and the way the Dell laptop handles graphics. These Dell laptops must pipe all graphics processing through the CPU integrated graphics including those processed by the external graphics card. For some reason, the axWindowsMediaPlayer object in C# doesn't play nice with that arrangement and causes an access violation.

    The workaround is to go into nVidia Control Panel, go to Manage 3D settings, open the Program Settings tab, and add the actual program executable files (in bin/Release and bin/Debug) to the list of programs, then change the preferred graphics processor to Integrated Graphics. Now I can run the executable files directly, or debug from within Visual Studio and it will not cause the crash.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.