Discussion:
Each time I use the Active X Automation Open feature a new Instance is created even if one already exists?
(too old to reply)
Ian Melville
2008-08-07 12:10:07 UTC
Permalink
The story so far...
 
I am using the Active X features to create an event callback structure in combination with a queue to achieve an event driven structure. The initial registration is performed in  a Sub VI using a Automation Open dialogue  and after completion the reference is stored in a variable created at the top level VI (not a global). Afterwards each time I try to reconnect to the interface of the COM object (normally for communication purposes via a CAN Bus) even though I pass the original stored reference into the Automation Open dialogue, a new instance is created of the COM Object. Consequently, multiple instances of the COM Object are created resulting in loss of synchronisation between the COM object and the LabView Program. As a result when the Lab View program is terminated the a fatal exception error occurs crashing the program.
 
So my questions are:
 
1. How can I ensure that the same reference is used (either directly or via the Automation Open dialogue after creation and that no additional Instances of the COM Object are created?
2. Is it possible to create the initial instance of the COM Object in a SubVI (limited scope) and store the reference created in a variable created in the Top Level VI that has been passed into the SubVI or is the reference always destroyed on leaving the Sub VI?
3. What effect does the Close Reference dialogue have on the referenced instance of the COM Object and when should it be used?
 
I have been trying to solve with this problem for a week with the Active X experts without success so I hope someone can help.
 
Many thanks in advance.
 
Ian Melville 
 
Wiebe@CARYA
2008-08-07 13:30:31 UTC
Permalink
Post by Ian Melville
1. How can I ensure that the same reference is used (either directly or
via the Automation Open dialogue after creation and that no additional
Instances of the COM Object are created?

Use Open Automation only once.
Post by Ian Melville
2. Is it possible to create the initial instance of the COM Object in a
SubVI (limited scope) and store the reference created in a variable created
in the Top Level VI that has been passed into the SubVI or is the reference
always destroyed on leaving the Sub VI?

Make an action engine. E.g. a while loop with a case. The while loop has a
shift register which holds the reference. The TRUE case does an open
automation, the false case simply passes the previous value.
Post by Ian Melville
3. What effect does the Close Reference dialogue have on the referenced
instance of the COM Object and when should it be used?

If you mean Close Reference function, it closes the reference, and releases
the object. You use it for each reference you've opened, once you're done
with it.

Regards,

Wiebe.
MikeS81
2008-08-07 12:40:05 UTC
Permalink
Hi Ian Melville,
you can check if the connected reference is valid. Use a case structure with true/false case. If the reference is valid use the reference, if not create a new one.
 
Hope it helps.Mike
Ian Melville
2008-08-07 12:40:10 UTC
Permalink
Hi Mike
Thanks for the quick reply. This is where I am a bit puzzled about the operation of the Automation Open dialogue. According to the help infomation when left in its default state the dialogue will first try and connect to an existing valid reference before creating a new reference/instance. This does not appear to work, at least not how I interperate the available information about how it should work. In any case what would you consider an appropriate test of whether a reference is valid (appart from a non-null value)? 
Regards
 
Ian
MikeS81
2008-08-07 12:40:11 UTC
Permalink
Hi Ian,
you can use a shift register to store your refnum and check it with "not a refnum". See the attached picture.
Hope it helps.Mike


Automation_Open.PNG:
Loading Image...
Ian Melville
2008-08-07 14:40:10 UTC
Permalink
Hi Wiebe.
Thanks for the input and the solutions when a reference is lost. What I'm still trying to understand is the reason/mechanism that causes the reference to be lost in the first place?  Is the storing of a reference in a cluster via a local variable for future use not allowed? The reason I ask is that the Program is nested structure with SubVi's within SubVi's which does not easily lend itself to the Action Engine structure that yourself and Mike suggested.
Regards
Ian
 
Wiebe@CARYA
2008-08-08 14:52:18 UTC
Permalink
Post by Ian Melville
Afterwards each time I try to reconnect to the interface of the COM
object (normally for communication purposes via a CAN Bus) even though I
pass the original stored reference into the Automation Open dialogue, a new
instance is created of the COM Object.

I think you need to tell us more about this. Most important question: how do
you notice that a new instance is created?

Normally, an external reference (.com or .net) should stay open untill
explicitelly closed. Now there might be an optimalisation bug or something,
but it's hard to tell without seeing any code.

Regards,

Wiebe.
Ian Melville
2008-08-11 09:40:12 UTC
Permalink
Hi Wiebe
I have the ability to debug the COM Object using .NET Visual Studio and can see that every time the interface is accessed the process to create a new instance is performed. During recent discussions it has become apparent that the because I have created the original instance/refnum in a SubVi when the SubVi is exited the instance resources are released thus causing the refnum to be no longer valid. As the COM Object needs a reference to the original instance to shutdown the event handling properly I need to ensure the original refnum/instance is not released until the end of the LabView program shutdown. Would a AE/FG actually help under these circumstances?
Best Regards
 
Ian Melville
Wiebe@CARYA
2008-08-11 11:00:08 UTC
Permalink
Post by Ian Melville
I have the ability to debug the COM Object using .NET Visual Studio and
can see that every time the interface is accessed the process to create a
new instance is performed. During recent discussions it has become apparent
that the because I have created the original instance/refnum in a SubVi when
the SubVi is exited the instance resources are released thus causing the
refnum to be no longer valid. As the COM Object needs a reference to
the original instance to shutdown the event handling properly I need to
ensure the original refnum/instance is not released until the end of the
LabView program shutdown. Would a AE/FG actually help under these
circumstances?

Why don't you give it a try? An AE/FG that buffers the reference woudn't
take much longer then 5 minutes to make. I can't do it for you, I don't have
.NET Visual Studion to debug the AX behaviour. That is a nice feature
though!

Regards,

Wiebe.

Continue reading on narkive:
Search results for 'Each time I use the Active X Automation Open feature a new Instance is created even if one already exists?' (Questions and Answers)
7
replies
What's your experience with Windows Vista?
started 2007-04-11 07:05:00 UTC
desktops
4
replies
Xbox 360????
started 2007-09-29 06:32:15 UTC
xbox
Loading...