类中调用界面ActiveX控件报错当前线程不在单线程单元中因此无法实例化 ActiveX 控件的解决办法
解决办法是Form类中定义一个静态的ActiveX对象,在formload中将界面上的ActiveX对象赋值给新定义的对象,类中访问该静态对象即可.
public static AxClientDriver_NTLib.AxClientDriverCtrl com = new AxClientDriver_NTLib.AxClientDriverCtrl();
private void Form1_Load(object sender, EventArgs e)
{
com = this.axClientDriverCtrl1;
isRunning = true;
this.FormClosing += Form1_FormClosing;
Thread t = new Thread(StartServer);
////t.SetApartmentState(ApartmentState.STA);//关键设置
t.Start();
}
public class A
{
public void GetZhiWen()
{
//new AxClientDriver_NTLib.AxClientDriverCtrl().GWQ_SignFinger(); /*报错:
当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“f1b35062-91ea-47fd-a71e-872c114220b0”。System.Threading.ThreadStateException: 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“f1b35062-91ea-47fd-a71e-872c114220b0”。*/
Form1.com.GWQ_SignFinger();
}
}
类中调用界面ActiveX控件报错当前线程不在单线程单元中因此无法实例化 ActiveX 控件的解决办法的更多相关文章
- 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件
“/”应用程序中的服务器错误. 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“c552ea94-6fbb-11d5-a9c1-00104bb6fc1c”. 说明: 执行当前 Web ...
- svn报错cleanup failed–previous operation has not finished; run cleanup if it was interrupted的解决办法
今天在svn提交的时候它卡顿了一下,我以为已经提交完了,就按了一下,结果就再也恢复不了,也继续不了了... 报错 cleanup failed–previous operation has not f ...
- 安装Phoenix时./sqlline.py执行报错File "./sqlline.py", line 27, in <module> import argparse ImportError: No module named argparse解决办法(图文详解)
不多说,直接上干货! 前期博客 Apache版Phoenix的安装(图文详解) 问题现象 Traceback (most recent call last): File , in <module ...
- .net winform 调用类中的webbrowser 报错:当前线程不在单线程单元中,因此无法实例化 ActiveX
遇到这个恶心的问题纠缠得不要不要的,大家遇到了的话希望不要走弯路,经过这个折腾让我有点怀疑人生了.哈哈哈 解决代码如下: //插入一个新线程用于处理验证码 Thread thd = new Threa ...
- 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“8856f961-340a-11d0-a96“
在做采集时,有些网页因服务器限制用webclient或者webrequest不能获取html,这时我们可以用webbrowser的方法来绕过对方服务器的限制,但是在实例化webbrowser 的时候发 ...
- Current thread must be set to single thread apartment (STA) mode before OLE,当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“8856f961-340a-11d0-a96b-00c04fd705a2”。
Add the STAThreadAttribute attribute on the Main method. This attribute is required if your program ...
- 启动IntelliJ IDEA 2016报错:cannot start under Java 1.7 : Java 1.8 or later is required 解决办法
idea64.exe启动错误:Cannot start under Java 1.7.0xxx IntelliJ IDEA : Unsupported java version Cannot star ...
- jeecg启动报错“com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.”的解决办法
在运行"maven build"-->"tomcat:run"之后,报如下错误: com.mysql.jdbc.exceptions.jdbc4.MySQ ...
- Android 运行报错 Unknown failure (at android.os.Binder.execTransact(Binder.java:681)) Error while Installing APKs 解决办法
今天,我用手机测试的时候出现了这个错误 我网站查找了一会资料, 在运行的时候出现提示大致意思:卸载删除已存在应用程序,是否卸载现有应用程序,点击ok就会出现如下错误 原应用程序也没有卸载,然后自己手动 ...
随机推荐
- JS 与 OC 交互
WebView与JS的几种交互 IOS中 使用JavaScriptCore 实现OC与JS的交互 JavaScriptCore 使用
- CoreImage 图片处理
CoreImage 是苹果 iOS5新增的一个 OC 框架,提供了强大的图像处理功能, 用于对基于像素的图像进行操作与分析, 提供了很多滤镜(Filter),形成强大的自定义效果 CIImage 类 ...
- java中引用
java中引用分为,强,弱,虚,软 (1)强引用 使用最普遍的引用.如果一个对象具有强引用,它绝对不会被gc回收.如果内存空间不足了,gc宁愿抛出OutOfMemoryError,也不是会回收具有强引 ...
- 评估指标:ROC,AUC,Precision、Recall、F1-score
一.ROC,AUC ROC(Receiver Operating Characteristic)曲线和AUC常被用来评价一个二值分类器(binary classifier)的优劣 . ROC曲线一般的 ...
- 时钟时间,系统cpu时间,用户cpu时间
进程的3种状态:阻塞,就绪,运行 度量一个进程的执行时间,unix为进程维护了3个时间,即时钟时间,用户CPU时间,系统CPU时间. 时钟时间又被称为墙上时钟时间,wall clock tim ...
- SAP Sybase IQ 操作基础
1.启动 source IQ-16_0.sh 命令行查看安装程序是否成功 start_iq -v2 2.数据库.表空间 start_iq -n utility_db dbisql -c 'uid=db ...
- mvc Area(区域)相关技术
ASP.NET MVC中,是依靠某些文件夹以及类的固定命名规则去组织model实体层,views视图层和控制层的.如果是大规模的应用程序,经常会由不同功能的模块组成,而每个功能模块都由MVC中的三层所 ...
- android viewpager 拿到当前显示的 fragment 的实例
一个 ViewPager 通过 FragmentPagerAdapter 绑定了 3 个 fragment 可以通过 Fragment fragment = getSupportFragmentMan ...
- IDEA里运行代码时出现Error:scalac: error while loading JUnit4, Scala signature JUnit4 has wrong version expected: 5.0 found: 4.1 in JUnit4.class错误的解决办法(图文详解)
不多说,直接上干货! 问题详情 当出现这类错误时是由于版本不匹配造成的 Information:// : - Compilation completed with errors and warnin ...
- 案例15-基本的表单校验使用validate
1 导入插件 <!--引入jquery相关文件 --> <script src="js/jquery-1.11.3.min.js" type="text ...