【发布时间】:2017-02-13 14:44:54
【问题描述】:
我的 Windows 窗体应用程序意外关闭,调试控制台在开始播放视频之前显示 AccessViolation 0xc0000005。
我正在使用以下代码开始视频:
private void Form1_Load(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"C:\Program Files\MyApp\Video.mp4";
axWindowsMediaPlayer1.Ctlcontrols.play();
}
如果视频结束关闭它并退出表单:
private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if(e.newState == 8)
{
axWindowsMediaPlayer1.close();
this.Close();
}
}
玩家的设计器代码
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);
调试输出:
程序“[(PID)] game.vshost.exe”已退出,代码为 -1073741819 (0xc0000005)“访问冲突”。
我曾尝试使用 try-catch,但没有发现错误。但问题不在于尝试捕捉。 应用程序正在以管理员权限运行。
来自 Windows 事件查看器的应用程序事件:
D3D9.DLL
错误应用程序名称:game.exe,版本:1.0.0.0,时间戳:0x58a1bd65
错误模块名称:D3D9.DLL,版本:10.0.14393.447,时间戳:0x5819bcea
异常代码:0xc0000005
故障偏移:0x0000000000010207
错误进程 ID:0x189c
错误的应用程序启动时间:0x01d2860e39d0d6e7
错误的应用程序路径:C:\Users\Lenovo\Desktop\game.exe
错误模块路径:C:\WINDOWS\SYSTEM32\D3D9.DLL
报告 ID:21a37f31-b9d0-4137-ad79-35d608e10916
错误包全名:
错误的包相关应用程序 ID:
NET 运行时
应用程序:game.exe
框架版本:v4.0.30319
说明:进程因未处理的异常而终止。
异常信息:期望代码 c0000005,期望地址 00007FFFD7490207
我的电脑是 Windows 10 Single Language 1607 (14393.693)
小提示:此错误在我 1 个月前创建或编辑后引发了我的所有项目。
更新:在 Windows Server 2012、Windows 8.1 和 Windows 7 虚拟机以及我的 PC 上会引发相同的错误
【问题讨论】:
-
AccessViolationException默认情况下不被捕获。检查事件查看器它应该包含有关崩溃的更多信息 -
Ofir Winegarten Windows 事件查看器,抓住这个但我什么都不懂:heypasteit.com/clip/3TWM1
-
应该有比你发布的更多的信息。日志中可能有两个不同的错误
-
从不详细的常规选项卡中复制文本
-
你试过用微软或VLC这样的视频播放器播放吗?
标签: c# .net windows-10 access-violation axwindowsmediaplayer