关闭AxWindowsMediaPlayer的窗体时出现AccessViolation异常 [英] AccessViolation exception when form with AxWindowsMediaPlayer closed

查看:182
本文介绍了关闭AxWindowsMediaPlayer的窗体时出现AccessViolation异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单上有一个 AxWMPLib.AxWindowsMediaPlayer 。当关闭表单时,我得到尝试读取或写入受保护的内存。这通常表明其他内存已损坏。例外。隐藏表单即可,但不能关闭。从窗体中删除组件后,一切都很好。

I have a AxWMPLib.AxWindowsMediaPlayer on a form. When I close the form, I get "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." exception. It is OK with hiding the form but not with closing. Everything's fine when the component is removed from the form.

这是Winforms .Net3.5。

This is Winforms .Net3.5.

任何

推荐答案

这是我的事情,这是在按键过程中关闭表单时出现的。

This was happening to me, and it was when closing the form during a key press.

如果WMP控件有要处理的关键事件,似乎会引起问题。

Seems the WMP control will cause problems if it has a key event to process.

Form.KeyPreview = True <的示例/ p>

Example with Form.KeyPreview = True

Sub Form_KeyDown(e As KeyEventArgs)
 AxWindowsMediaPlayer1.Dispose()
End Sub

导致访问冲突。

Sub Form_KeyDown(e As KeyEventArgs)
 e.Handled = True
 AxWindowsMediaPlayer1.Dispose()
End Sub

干净地关闭,因为按键无法进入WMP控件。

Closes cleanly, as the key press is blocked from reaching the WMP control.

关闭,将要处理该控件。

Same thing happens when the form is closed as will dispose of the control.

这篇关于关闭AxWindowsMediaPlayer的窗体时出现AccessViolation异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆