LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Caching COM Interface

Hi all
I am writting a program that uses COM interfaces.
A VI obtains a COM interface from the DLL server and is
attempting to cache the interface pointer for use with other
VIs. But when the other VI tries to use the interface,
the interface pointer is no longer valid. Why ?

I confirmed that the object the interface is pointing is still
active, but I can"t see why an interface pointer can't be used
between multiple VIs.

Thanks
Makoto
0 Kudos
Message 1 of 4
(3,553 Views)
> I am writting a program that uses COM interfaces.
> A VI obtains a COM interface from the DLL server and is
> attempting to cache the interface pointer for use with other
> VIs. But when the other VI tries to use the interface,
> the interface pointer is no longer valid. Why ?
>
> I confirmed that the object the interface is pointing is still
> active, but I can"t see why an interface pointer can't be used
> between multiple VIs.
>

This is something that can happen with any form of I/O refnum
in LV. They are garbage-collected whenever the top-level VI
that they were allocated as a part of finishes running.

To resolve your specific question, you can write a refnum into
a global or whatever else for storage and use it as long as the
top-level VI that it was all
ocated on behalf of is still running.
When the VI finishes, the references are all released, and any
actions on those refnums should return an error.

Notice that the refnum isn't the same as an interface pointer.
The interface pointer is stored in a table for garbage collection,
and the refnum points to that.

I hope this clears things up.
Greg McKaskle
0 Kudos
Message 2 of 4
(3,553 Views)
"Makoto" wrote:
>Hi all>I am writting a program that uses COM interfaces.>A VI obtains a
COM interface from the DLL server and is>attempting to cache the interface
pointer for use with other>VIs. But when the other VI tries to use the interface,>the
interface pointer is no longer valid. Why ?>>I confirmed that the object
the interface is pointing is still>active, but I can"t see why an interface
pointer can't be used>between multiple VIs.>>Thanks>Makoto>>

Hi,
0 Kudos
Message 3 of 4
(3,553 Views)
Hi,> Are the two vi's running separate threads, if so then the interface poionters
will have to be marshalled from one to the other not just copied. Is the
server an inprocess server and what threading model is it implementing? >>>
Dan
0 Kudos
Message 4 of 4
(3,553 Views)