vb2008调用dll的问题
一个dll文件拷贝到的System32目录下,在VS2008里添加了引用,在程序中的代码如下:Imports Axzkemkeeper
Public Class downRec
Public Sub dlData()
Dim AxCZKEM1 As New Axzkemkeeper.AxCZKEM
If AxCZKEM1.Connect_Net(ip, 4370) Then
If AxCZKEM1.ReadGeneralLogData(macNumber) Then
While AxCZKEM1.GetGeneralLogDataStr(macNumber, dwEnrollNumber, dwVerifyMode, dwInOutMode, timestr)
...
运行后出现如下错误:
ActiveX control '00853a19-bd51-419b-9269-2dabe57eb61f' cannot be instantiated because the current thread is not in a single-threaded apartment.
请大家明示一下,如何更改 --------------------编程问答-------------------- 找到
[STAThread]
void main()
前面加上如示属性 --------------------编程问答-------------------- 程序里没有楼上所说的这些东西啊 --------------------编程问答-------------------- VB应该是 Sub Main()。 --------------------编程问答--------------------
让你加上[STAThread]属性 --------------------编程问答-------------------- 是需要在单线程内执行
参考
http://msdn.microsoft.com/en-us/library/ms693344(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms680112(VS.85).aspx --------------------编程问答-------------------- 4楼的能否说清楚点 --------------------编程问答-------------------- ActiveX控件'00853a19 - bd51 - 419B章- 9269 - 2dabe57eb61f'不能被实例化,因为当前线程不是在一个单线程单元。
System.Threading.Thread s = new System.Threading.Thread(new System.Threading.ThreadStart(test));
s.ApartmentState = System.Threading.ApartmentState.STA;
s.Start();
或
主程序加[STAThread]属性 --------------------编程问答-------------------- 同意楼上所说 --------------------编程问答-------------------- com组件和dll文件时两码事,处理的方法也不一样
补充:.NET技术 , VB.NET