Hi,
I have got a question about AxInterOp and InterOp.
When I add a com control to my form, it automatically adds two references to my project; Ax<>.dll and <>.dll. After some research I found that the Ax-dll is the actual component used for the form (visibility) and VS automatically uses it when I add that control to my form.
The problem is; I need that control to be running in another thread, and I don't need the control to be visible on a form or something. I thought that would be possible somehow, so I started experimenting a bit. I thought that I could use the <>.dll class for that, because the Ax<>.dll did not work; it resulted in a threading error that I couldn't use it because it wasn't running in a single-threaded apartment.
So after some experimenting I made some code which I thought could work correctly:
'this in Form1_load()
t = New Thread(AddressOf interrupt)
t.Name = "Interrupt"
t.Start()
'this in sub interrupt()
Dim TVicLPT2 As TVICLPTLib.TVicLPT = New TVICLPTLib.TVicLPT()
TVicLPT2.Active = 1
TVicLPT2.IrqNumber = 7
TVicLPT2.UnmaskIrq()
AddHandler TVicLPT2.LptInterrupt, AddressOf TVicLPT2_LptInterrupt
Where I have got the TVICLPTLib and AxTVICLPTLib as the two dll's imported to my project.
But now when I run it, it gives me the following error at the line TVicLPT2.Active = 1 (and it also gives me that error for the Irqnumber and UnmaskIRQ() line. The AddHandler line doesn't produce an error, but the event doesn't fire when trying it):
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
I guess this has something to do with using the <>.dll instead of Ax<>.dll and then not being able to do such things. Is this true? If so, is there another way to accomplish what I'm trying to do. If it isn't true, what should I change in my code to make it work?
Thanks in advance,
Floris
I have got a question about AxInterOp and InterOp.
When I add a com control to my form, it automatically adds two references to my project; Ax<>.dll and <>.dll. After some research I found that the Ax-dll is the actual component used for the form (visibility) and VS automatically uses it when I add that control to my form.
The problem is; I need that control to be running in another thread, and I don't need the control to be visible on a form or something. I thought that would be possible somehow, so I started experimenting a bit. I thought that I could use the <>.dll class for that, because the Ax<>.dll did not work; it resulted in a threading error that I couldn't use it because it wasn't running in a single-threaded apartment.
So after some experimenting I made some code which I thought could work correctly:
'this in Form1_load()
t = New Thread(AddressOf interrupt)
t.Name = "Interrupt"
t.Start()
'this in sub interrupt()
Dim TVicLPT2 As TVICLPTLib.TVicLPT = New TVICLPTLib.TVicLPT()
TVicLPT2.Active = 1
TVicLPT2.IrqNumber = 7
TVicLPT2.UnmaskIrq()
AddHandler TVicLPT2.LptInterrupt, AddressOf TVicLPT2_LptInterrupt
Where I have got the TVICLPTLib and AxTVICLPTLib as the two dll's imported to my project.
But now when I run it, it gives me the following error at the line TVicLPT2.Active = 1 (and it also gives me that error for the Irqnumber and UnmaskIRQ() line. The AddHandler line doesn't produce an error, but the event doesn't fire when trying it):
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
I guess this has something to do with using the <>.dll instead of Ax<>.dll and then not being able to do such things. Is this true? If so, is there another way to accomplish what I'm trying to do. If it isn't true, what should I change in my code to make it work?
Thanks in advance,
Floris