UKTAG – UK Test Automation Group

cancel
Showing results for 
Search instead for 
Did you mean: 

C# Application threads, throwing Errors AND TestStand

Hi All,

 

This may be really more a C# question than a TestStand question, but any pointers would be very helpful to me as I have a sore head reading C# blogs and help file today. Please forgive the length of this post

 

I have created a very small and simple C# Windows Form, so I can play calling it from TestStand and it generally does what I want and seemed good 🙂

 

I created a little plugin in ProcessModelPostStepRuntimeError to trap errors sent back from my little dll to TestStand using  error.Occurred, Error.Message and Error.Code cluster, a simple a tickbox and two entry windows and exit button on the form, again so far so good.

 

So I now wanted to move to handling Exceptions. I put two buttons on the form with the following code show below, the idea was to simulate Exceptions, I catch the Exceptions and throw them up into the very small code the creates and start the form. 

 

The following is what happens

What I run TestStand, my for pops up If I press a button to causes the exception some Visual Studio exception handler popup appears and the form just stays running.

 

If however I try to debug it by attaching to the SeqEdit process,  I see an unhandled exception in the debugger and when I press continue TestStand get as shows the correct message, if I STOP the VS debugger and run the test sequence everything works great until I close TestStand and reopen it.

 

So I understand that my throw on the Windows form acts as an unhandled error causing the popup and that I need to somehow using Application.ThreadException  to tie the form to TestStand and this is somehow automatically happening when I attach VS to the SeqEdit process.

 

Any pointer, guidance or recommended reading would be appriciated.

 

cheers 

 

Danny 

 

 

=================================================================

private void forceFileErrorBtn_Click(object sender, EventArgs e)
{
try
{
// This will throw a FileNotFound error
FileStream fs = File.Open("Z:/False.txt", FileMode.Open, FileAccess.Write);
}
catch (Exception exception)
{
throw new Exception("Attempted to open file that does not exist",exception);
}
}

 


private void forceDaqMxErrorBtn_Click(object sender, EventArgs e)
{
try
{
// This will throw an invalid identifier error
Device dev = DaqSystem.Local.LoadDevice("PxiOnAnotherPlanet");
}
catch (Exception exception)
{
throw new Exception("Attempted to access invalid PXI device", exception);
}

 

 

==================

In form creator / caller.

 

 

catch (Exception ex)
{
errorOccurred = true;
errorMsg = ex.Message;
errorCode = 4;
return this.mReturnData;
}

 

Danny Thomson AshVire Ltd
0 Kudos
Message 1 of 1
(2,626 Views)