12-09-2008 06:18 AM
Hi,
I have built a .NET C# wrapper around the User Management module of TestStand.
When the application works as a standalone Windows Application, there are no exceptions or errors thrown. However, when the dll is integrated with TestStand and called from the FrontEndCallbacks sequence file, I am thrown an 'Invalid cast' exception when AutoCompleteStringCollection is assigned to a textBox's AutoCompleteCustomSource property.
As previously stated, it works perfectly fine when it's a stand alone application. I am at a loss to figure why this is happening. I would really appreciate if anybody could throw some light on this behaviour.
Thanks
Arun
Solved! Go to Solution.
12-11-2008 11:30 PM
Hi Arun,
What do you mean by standalone application? Does it mean using the DLL seperately in some other application like LabVIEW?
Invalid cast exception can be due to TestStand not accepting the data type associated coming from/ required by your DLL.
Can you share your DLL and the sequence file so that me as well as other user can have more information?
Regards
Vaibhav
12-16-2008 01:08 AM
Hi Vaibhav,
By stand alone, I mean that the application can also work as a windows application. However, by making the application into a dll, the application is invoked through TestStand.
Unfortunately, I cannot the share the original dll for security purposes. However, I have posted a sample dll and the associated pdb file along with the sequence file.Hope it helps.
Regards
Arun
12-16-2008 09:02 AM
Thank you for posting your example. The problem appears to be caused by the fact that your form is created in a TestStand execution thread which uses the MTA COM threading model. .NET Windows forms should always be created in threads marked with the STA threading model. Your standalone application no doubt uses the STAThread attribute. Here are a couple of references (FxCop Rule, STAThread)
You can work around this problem by creating a new STA thread in TestStand using a sequence call step. Set the Execution Options to Use New Thread and check the Use Single-Threaded Apartment checkbox.
12-18-2008 12:28 AM