怎么在Windows Service 里使用 ActiveX
我有一个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)