axWindowsMediaPlayer,我有窗体里有这个控件,
代码这是样的
WMPLib.IWMPMediaCollection mediacollection;
WMPLib.IWMPMedia media;
private void Form1_Load(object sender, EventArgs e)
{
classsql cnn = new classsql();
string sqlstrtype = "select * from dianying";
SqlDataReader drtype = cnn.sql_drcx(sqlstrtype);
mediacollection = axWindowsMediaPlayer1.mediaCollection;
while (drtype.Read())
{
media = mediacollection.add(drtype.GetString(3).ToString());
axWindowsMediaPlayer1.currentPlaylist.appendItem(media);
}
cnn.sql_close();
}
生成的时候没有错误,可是一运行就就要报错
报错内容:
未处理的“System.Runtime.InteropServices.COMException”类型的异常出现在 WindowsApplication5.exe 中。
其他信息: 异常来自 HRESULT:0xC00D1324
可是我把代码改成:
WMPLib.IWMPMediaCollection mediacollection;
WMPLib.IWMPMedia media;
private void Form1_Load(object sender, EventArgs e)
{
classsql cnn = new classsql();
string sqlstrtype = "select * from dianying";
SqlDataReader drtype = cnn.sql_drcx(sqlstrtype);
mediacollection = axWindowsMediaPlayer1.mediaCollection;
drtype.Read();
media = mediacollection.add(drtype.GetString(3).ToString());
axWindowsMediaPlayer1.currentPlaylist.appendItem(media);
cnn.sql_close();
}
运行就不会有问题,为什么呀,求高手指点