惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - kongxx

Java & .Net通讯问题 无异间发现的好网站 使用log4net记录日志到MySQL中 C#的MD5实现 Java的MD5实现 PHP实现的Telnet 【引用】 microsoft WINDOWS 系统错误代码 [收藏] PicoContainer学习手册 PicoContainer学习手册 Java动态代理实现 [导入]Digester学习笔记 [导入]使用对Ant编程来实现简单文件的打包 [导入]关闭WinXP自带的Zip功能 [导入]使Tomcat可以下载中文文件 [导入].Net中使用com组件后发生System.ArithmeticException异常的解决办法 [导入]使用简单的Web开发架构 [导入].Net配置文件常用配置说明 [导入]使控件拥有透明背景色 [引用] [导入].Net配置log4net
Message: 因为当前线程不在单线程单元中,故无法实例化 ActiveX 控件 错误处理方法
kongxx · 2005-10-27 · via 博客园 - kongxx

最近在做一个简单的屏幕保护程序,功能很简单就是在机器长时间不用的情况下,间隔一定时间启动一个屏幕保护程序。我这里有个特殊情况就是要播放一些媒体文件(.avi,.wmv)和flash文件等,因此我使用的是windows自带的WindowsMediaPlayer来做播放器。
由于一些特殊原因,我需要在一个没有GUI的程序中启动屏幕保护程序,因此最初使用的是System.Threading.Timer来做定时器的,但是在测试中发现总是出席以下异常:
Message: 因为当前线程不在单线程单元中,故无法实例化 ActiveX 控件“6bf52a52-394a-11d3-b153-00c04f79faa6”。
Source: System.Windows.Forms
   at System.Windows.Forms.AxHost..ctor(String clsid, Int32 flags)
   at System.Windows.Forms.AxHost..ctor(String clsid)
   at AxWMPLib.AxWindowsMediaPlayer..ctor()
   ...
后来弄了好长时间才发现,原来WindowsMediaPlayer控件只能在单线程环境下才可以运行,后来将我的Timer改成System.Windows.Forms.Timer对象,再进行测试,一切OK!

总结:通过这次错误发现自己在写一些程序的时候没有很好的阅读MS的开发文档,主要是没有关注线程安全方面的东西,下次开发中需要特别提出注意.