问题:
如果winform中的WMP模块报错,则参照如下办法:
this.axMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer(); //当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“6bf52a52-394a-11d3-b153-00c04f79faa6”
解决方法:
在main()主函数前面加 [STAThread]
其他:
VB项目的默认线程模型是单线程套间(SingleThreaded Apartment),而C#项目的默认线程模型是多线程套间 (Multithreaded Apartment)。
如果你想把STAThread attribute加进C#的主方法里面,如下:
[STAThread]
static void Main()