My Windows Form Application is closing unexpectedly and the debug console says AccessViolation 0xc0000005 before starting to play the video.
I'm starting the video with the following code:
private void Form1_Load(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"C:\Program Files\MyApp\Video.mp4";
axWindowsMediaPlayer1.Ctlcontrols.play();
}
If video ends close it and exit from form:
private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if(e.newState == 8)
{
axWindowsMediaPlayer1.close();
this.Close();
}
}
Player's designer code
this.axWindowsMediaPlayer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
this.axWindowsMediaPlayer1.Enabled = true;
this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(0, 0);
this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1";
this.axWindowsMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWindowsMediaPlayer1.OcxState")));
this.axWindowsMediaPlayer1.Size = new System.Drawing.Size(1906, 1066);
this.axWindowsMediaPlayer1.TabIndex = 2;
this.axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(this.axWindowsMediaPlayer1_PlayStateChange);
Debug Output:
The program '[(PID)] game.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
I have tried to use try-catch but the error isn't being catched. But the problem isn't try-catch. Application is running with administrator rights.
Application's event from Windows Event Viewer:
D3D9.DLL
Faulting application name: game.exe, version: 1.0.0.0, time stamp: 0x58a1bd65
Faulting module name: D3D9.DLL, version: 10.0.14393.447, time stamp: 0x5819bcea
Exception code: 0xc0000005
Fault offset: 0x0000000000010207
Faulting process id: 0x189c
Faulting application start time: 0x01d2860e39d0d6e7
Faulting application path: C:\Users\Lenovo\Desktop\game.exe
Faulting module path: C:\WINDOWS\SYSTEM32\D3D9.DLL
Report Id: 21a37f31-b9d0-4137-ad79-35d608e10916
Faulting package full name:
Faulting package-relative application ID:
NET Runtime
Application: game.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: expection code c0000005, expection address 00007FFFD7490207
My PC is Windows 10 Single Language 1607 (14393.693)
TINY NOTE: This error throwns all of my Projects after created or edited 1 month ago.
UPDATE: The same errors are thrown on the Windows Server 2012, Windows 8.1 and Windows 7 Virtual Machines and my PC