NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Releasing an Object created with ActiveXAdapter

Solved!
Go to solution

Hi,

 

I have an ActiveX Object (HyperAccess) that uses the ActiveXAdapter.

Is i created during runtime. The communication is working fine.

But i am not able to call ReleaseDispatch. Its not accessible the HyperAccess interace.

 

 

It there a way to release ActiveX  (IDispatch) Objects during runtime?

 

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 1 of 4
(3,696 Views)
Solution
Accepted by topic author j_dodek

Just set all the variables storing the reference to Nothing.

 

Example:

 

Locals.MyActiveXReference = Nothing

 

Reference counting is handled automatically by Object Reference variables. If you have the activeX step set to create the object at load/unload time you will need to unload the step too though (but this is not the default setting).

 

Hope this helps,

-Doug

Message 2 of 4
(3,689 Views)

Hi Doug,

 

It seems this is right! Thanks.

But it is not working correctly after setting to nothing the Programm is crashing with an exception.

 

I have written a small c++ project to verfiy this behavoir.  There I used the same funtions calls as in TS.

There was no crashing.

 

But i also realized that there is a problem with the programm itself. If makeing the HyperAccess Window once visible

you never will be able to remove the process.

 

So to save time, i will do a workaround by hooking the window with AutoIt and send ALT-F4

 

Greetings

Juergen

 

 

 

 

 

   

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 3 of 4
(3,675 Views)

One difference might be that TestStand releases objects in a separate thread. In a well behaved COM/ActiveX server this should not matter and should be handled by the COM/ActiveX threading model. If, however, the server was not written with the correct COM threading model then this might lead to problems. If your server is an in process .dll server and interacts with windows (which have thread affinity) and thus always needs to be called from the same thread, it should be an STA - Single Threaded Apartment server rather than an MTA - Multithreaded Apartment server. If this server is one you have source code to, you might want to check to see if that is the problem.

 

Hope this helps,

-Doug

0 Kudos
Message 4 of 4
(3,659 Views)