08-20-2009 01:03 PM
The specific error that I was encountering is
"The value for the .NET parameter 'ii' could not be returned.
Specified cast is not valid."
08-20-2009 02:15 PM
I was able to make it work.
See my attach sequence solution.
.. the changes in the method below:
public void LoadAnotherObject()
{
Instrument i = new Instrument();
i.Name = "sample1 from ss";
i.Command = "boom boom pow";
// the instrument is local variable that will return in the getter of StationSetup instrument property.
instrument = i;
}
This solution though is not output parameter it works for now but I will be interested to see the alternative solution.
08-21-2009 05:23 PM
mbda,
1) Using an out or byref parameter is what I meant and it should work for passing a .NET object reference back to teststand (which can later be used with the dotnet adapter to pass in a .NET object to a method or to call methods on). I tried it using the following C# classes and it worked for me:
public class testclass1
{
public int x;
public string y;
}
public class testclass2
{
public void mymethod(out testclass1 arg)
{
testclass1 foo = new testclass1();
foo.x = 7;
foo.y = "bar";
arg = foo;
}
public void mymethod2(testclass1 arginput)
{
System.Windows.Forms.MessageBox.Show(arginput.y);
}
}
I basically just made two method calls in the sequence, the first to mymethod and stored the output parameter in a local variable of type Object Reference. I then called mymethod2 and passed the local variable as the input parameter and it worked as expected showing the correct value in the messagebox.
2) The example you attached, just contains a sequence file so I cannot use it to reproduce the problem you are seeing or see the source code to see if something might be incorrect.
3) What do you mean by "It is an ok work around, it is running fine insing teststand but it is throwing me similar error (the one that I originally reported) when I am running it in .NET framework."? Do you mean that your sequence is now working fine if you do what I suggested? What is the way you are using it that's not working then. Do you mean if you call your code directly from other C# code it's not working? If so, I strongly suspect it's for a different reason, please attach sample code which reproduces the problem.
4) If you are still having trouble getting out/byref .NET objects returned back to teststand like I suggested, please attach a sample sequence with sample source code for the assembly that reproduces the problem.
Hope this helps,
-Doug