01-17-2013 03:17 AM
It seems like a stupid question which will have an obvious answer but I'm stuck so....
I am using Visual C# express 2008 to make my dll and would like to call my methods from TestStand 2012. I have taken the default Dotnet template, added the ref to the project and kept it deliberately simple for the purpose of this test; here it is:-
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingNationalInstruments.TestStand.Interop.API; // TestStand Core API. Add <TestStand>\API\DotNet\Assemblies\CurrentVersion\NationalInstruments.TestStand.Interop.API.dll to your project as a reference.
usingSystem.Runtime.InteropServices;
namespace
TestStand_IF
{
classDummyClassName
{
publicvoid DummyFunctionName(SequenceContext seqContext, outString reportText, outbool errorOccurred, outint errorCode, outString errorMsg)
{
reportText =
String.Empty;
errorOccurred =
false;
errorCode = 0;
errorMsg =
String.Empty;
try
{
// INSERT YOUR SPECIFIC TEST CODE HERE
reportText = "Success !";
// The following code shows how to access properties and variables via the TestStand API
// PropertyObject propertyObject = seqContext.AsPropertyObject();
// String lastUserName = propertyObject.GetValString("StationGlobals.TS.LastUserName", 0);
}
catch(COMException e)
{
errorOccurred =
true;
errorMsg = e.Message;
errorCode = e.ErrorCode;
}
}
}
}
I add a "String Value" step in TestStand and alsign my dll but there is nothing to select in the root class box. I remember having similar problems maybe a decade ago in C - having to mark functions for export and checking that the type library was included but I don't think this is the case here.
Solved! Go to Solution.
01-17-2013 03:31 PM
Hi,
Try
Public DummyClassName
Curt
01-17-2013 03:31 PM
As far as I know, you can't just call a method in a class in C#.
You need to create a new object of that class.
If you want to be able to create a method without first creating an object, you can make that method Shared.
01-18-2013 03:38 AM
Thank you Curt,
I said It would be something obvious ;o)
01-18-2013 03:43 AM
I had wondered about this myself. Why there is no constructor in the template but I guess, now that I can see the class, I can add constructor(s). I'll keep you all posted.
Thanks for your help
01-18-2013 06:32 AM
All works fine, even without a constructor; don't know how but it does.
Thanks for everyones help..