我有一个Windows Service,启动的时候会调用 ClassLibrary1.Form1,Form1上有一个ActiveX。
服务使用帐号 Local System,而且允许服务与桌面交互。
但是发生错误,该怎么解决啊:System.Threading.ThreadStateException: 因为当前线程不在单线程单元中,故无法实例化 ActiveX 控件“b0b25446-7656-456c-8d3c-60a0ac6eac49”。
at System.Windows.Forms.AxHost..ctor(String clsid, Int32 flags)
at System.Windows.Forms.AxHost..ctor(String clsid)
at AxJDSMSCtrl.AxJindiSMSControl..ctor()
at ClassLibrary1.Form1.InitializeComponent()
at ClassLibrary1.Form1..ctor()
at WindowsService1.Service1.OnStart(String[] args)
服务使用帐号 Local System,而且允许服务与桌面交互。
但是发生错误,该怎么解决啊:System.Threading.ThreadStateException: 因为当前线程不在单线程单元中,故无法实例化 ActiveX 控件“b0b25446-7656-456c-8d3c-60a0ac6eac49”。
at System.Windows.Forms.AxHost..ctor(String clsid, Int32 flags)
at System.Windows.Forms.AxHost..ctor(String clsid)
at AxJDSMSCtrl.AxJindiSMSControl..ctor()
at ClassLibrary1.Form1.InitializeComponent()
at ClassLibrary1.Form1..ctor()
at WindowsService1.Service1.OnStart(String[] args)
解决方案 »
- 就急!!! gridview问题 求助!!!
- 请教高手,一个字符串排序问题
- 请问sqldatasource 连接不上局域网数据库
- C#中,有什么技术可以将多线程应用在界面绘制上?
- splist
- 关于oracleCommand1.Parameters["时间"]的问题 在线等
- 有没有想开软件公司的朋友
- CSC.exe 参数如何加入有空格的目录名?
- 加急!!!C#一, 如何获取VISTA管理员权限,以避免UAC弹出窗口;二,XP&vista下C#中如何创建、取消、删除、还原 系统还原点?
- 如何设置“显示”控制面板中的监视器颜色深度?
- 为什么访问不了XML?
- 100分求DateTimePicker的一个问题。
这个 Service 要求串口通讯,而这个功能是一个第三方的 ActiveX 提供的,
所以 Service 必须调用这个 OCX
1. On What login credentials this service is running ?
2. This user has sufficient previlages to access resources , if not try changing the user accounts?
3. Is this service making calls to other assemblies dynamically or other COM Dlls dynamically if so make sure these assemblies exist at proper path and Com Dlls are registered.
4 OnStart has to terminate in 30 seconds or service manager shuts down the service. It's possible that CLR cannot be loaded up timely.
"因为当前线程不在单线程单元中,故无法实例化 ActiveX 控件"
我是个developer,上述原因都不可能存在因为同样的程序 WinForm 就能运行
static void Main()
{
................
}
?