LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using .NET objects in CVI from TestStand

I am trying to pass a .NET handle from TestStand (3.5) to a LabWindows/CVI (8.0) C routine for further manipulation.  The handle is currently stored in FileGlobals as an Object Reference, and I have no problems using it from a sequence step.  However, trying to use the handle in CVI results in an application crash.  I am using the wrapper code generated by CVI for the assembly (used Create .NET Controller function) and have initialized the assembly.  Code as follows:
 
    Roche_Driver_SSSIRMate210_Utility_MultiDimByteArray_MultiDimByteArray MultiDimByteObject;
    int result, numOfReceivedPackets;
    ...    
    tsErrChk(TS_PropertyGetValIDispatch(testData->seqContextCVI, &errorInfo,
             "FileGlobals.RawTimeResolveData", 0, (CAObjHandle *)(&MultiDimByteObject)));
             
    result = Initialize_Roche_Driver_SSSIRMate210();
    result = Roche_Driver_SSSIRMate210_Utility_MultiDimByteArray_MultiDimByteArray_Get_Count(
    MultiDimByteObject, &numOfReceivedPackets, NULL);
 
Help greatly appreciated,
 
Steve Shelley
0 Kudos
Message 1 of 4
(3,591 Views)

The CDotNetHandle handles in the CVI generated wrappers are specific to the CVI .NET library. TestStand .NET references (handles) are specific to TestStand and cannot be passed to the CVI wrapper functions. The crash is due to this - passing an invalid handle to CVI.

If you really need to interoperate .NET object between TestStand and CVI, you should use some kind of .NET remoting mechanism to be able to access the object from multiple .NET AppDomains (application domains). This requires that the underlying .NET object is remotable and is not possible for most .NET objects - also, .NET remoting is an advanced and involved topic. Instead, I would recommend keeping your .NET client code entirely in TestStand or entirely in CVI, and call the appropriate environment from the other when you need to call .NET.

0 Kudos
Message 2 of 4
(3,571 Views)
Also you seem to be obtaining a COM handle (CAObjHandle for an IDispatch interface) from TestStand and passing this as a CDotNetHandle to the CVI .NET wrapper function! These are different incompatible handle types.
0 Kudos
Message 3 of 4
(3,566 Views)
Thanks, I was afraid the answer would be something along this line.  This is part of an application where one of the components has been moved from ActiveX to .NET.  I knew things were going too smoothly...
 
[The IDispatch attempt was just one of many permutations hoping to stumble across a solution]
 
Thanks for the assist!

Message Edited by S Shelley on 11-14-2006 04:14 PM

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