07-25-2012 04:06 AM
I have attached example projects showing what I am trying to do.
In the sequence the 'GetObject' step calls the 'GetClass' method from the dll, which returns the .NET object in the type defined by the .NET controller wrapper in CVI.
I'm trying to store this object in CVI while other steps are taken (this steps are ommitted from the example) Then pass it back to CVI later (the 'Pass/Fail Test' step in the example).
When I originally select the 'GetClass' method in the 'GetObject' step you get the message I described in my previous post about TestStand not recognising the type. I cannot get TestStand to hold onto a valid reference to this object.
Thank you all for your help.
07-25-2012 04:38 AM
i think the most prominent question is still:
Why don't you just use the .NET assembly itself directly in TestStand? You are complicating things by encapsulating the assembly into a static library (DotNetController) which is wrapped in a CVI DLL which is again called from TestStand. You have THREE(!) interfaces here which can introduce issues vs. ONE if calling the assembly directly from TestStand.
That being said/asked, there are some other questions:
a) Using debugging: Is the local variable Locals.ClassReference changing from Nothing to some hex-values after the step GetObject is called?
b) Are you sure that your function GetClass is returning a handle to the object which is recognized as "using the object" and not trying to return the object itself?
I find it possible that either the object is not constructed properly at all or that .NET garbage collection is destroying the object despite that TestStand is keeping a handle to it....
hope this helps,
07-25-2012 01:24 PM
Here are the steps that I took to reproduce the setup you are trying to use. This example calls a .NET method in CVI (from mscorlib), and passes the object reference back to TestStand. See below for the steps taken:
1. Open CVI and create a new project.
2. Tools > Create .NET Controller
3. Select from GAC: mscorlib (Version 220.127.116.11)
4. Use Browse... to set a path for the created instrument (MyInstrument.fp)
5. Check 'Add Instrument to Project'
6. Click OK
7. This may take awhile. Do you want to continue? (Yes)
8. Another dialog about which identifiers (OK)
9. Save project as 'Testing.prj' when prompted.
10. Success! (OK)
11. Build > Target Type > Dynamic Link Library
12. File > New > File From Template... (OK)
13. Created code and built a .DLL in CVI
14. Open TestStand
15. Add a CVI Action Step
16. Configure Step
16.a. Module: Testing.dll (the .dll I created)
16.b. Function: Test_Function
16.c. timezone Category : Pointer/Handle
16.d. timezone pass : By Reference (by pointer)
17. Create a local TestStand variable: Insert Local > Object Reference (named TestStandTZ)
18. In the step we created, set the timezone Value Expression to Locals.TestStandTZ
07-25-2012 03:23 PM
You will also want to be sure that you do not close the handle in CVI until you are completely done with it.