.net appdomain中的Activex对象实例-STA问题 [英] Activex object instance in .Net appdomain - STA Problem

查看:92
本文介绍了.net appdomain中的Activex对象实例-STA问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



环境:VS 2003,Windows服务应用程序.

我有一个Windows服务应用程序,可以创建多个appdomains(用于ex 4).使用domain.ExecuteAssembly ["Myassembly.exe"]方法.该应用程序使系统能够打开端口[TCP/IP或COM]并等待数据.因此,在myassembly.exe中,我需要为每个端口创建线程.我已经完成了,端口也处于侦听模式.

但是问题是,每当我从特定端口接收数据时,我都需要通过vbscript对其进行解析.为此,我使用了activex控件.[AxMSScriptControl.AxScriptControl]我无法在所有appdomain中为此控件创建实例.

我收到以下错误.

"Could not create instantiate for Activex Control ''XXX-XXX'' becuase the current thread is not in a single - threaded apartment" [STA].


谁能建议我如何在Appdomain中为activex对象创建实例.

谢谢,
Naveen

Hi,

Environment: VS 2003, Windows service application.

I have a windows service application which creates multiple appdomains[for ex 4]. using domain.ExecuteAssembly ["Myassembly.exe"] method. This application enables the system to open the ports[TCP/IP or COM] and waitfor the data. So In myassembly.exe i need to create thread for each port. I have done it and the port is also in listen mode.

But the problem is whenever i receive the data from a particular port i need to parse it by vbscript. For that i am using an activex control.[AxMSScriptControl.AxScriptControl] I am not able to create instance for this control in all appdomains.

I am getting the following error.

"Could not create instantiate for Activex Control ''XXX-XXX'' becuase the current thread is not in a single - threaded apartment" [STA].


Can any one suggest me how to create an instance for activex object in Appdomain.

Thanks,
Naveen

推荐答案

最简单的答案是不要在Windows服务中使用ActiveX,而要找到另一种方法,因为大多数ActiveX控件必须以某种形式托管. (无论如何,ActiveX都是废话.)

您是否真的需要使用VBScript解析传入的数据?它是什么样的数据?

The easy answer is to not use ActiveX in a windows service, and find another way to do it because most ActiveX controls must be hosted in a form. (ActiveX is crap anyway.)

Do you *really* need to parse incoming data with VBScript? What kind of data is it?


这篇关于.net appdomain中的Activex对象实例-STA问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆