Module error is causing calling app to crash

Class library usage, coding and language questions.
SeanP
Posts: 60
Joined: Wed Sep 01, 2010 11:48 pm
Location: Irvine California

Module error is causing calling app to crash

Post by SeanP » Fri Jul 08, 2011 12:26 am

I make a call in my code to the Start function of a recording done in version 3.0.2 and when the code is executing, the failing validation causes my application to crash.

I have posted the repository and the recording c# files.

Here is my calling code and how i have implemented it. I hope I am catching all the other exceptions.

Is there something that I am missing?

Code: Select all

 
string logFileName = Application.StartupPath + @"\Test.rxlog";

            try
            {
                Keyboard.AbortKey = Keys.Pause;
                //Setup the log file
                Report.Setup(ReportLevel.Info, logFileName, true);
                //This function should be overidden by any inherting class.
                RanorexStart();

                Report.End();

                base.Result = "Pass";
            }

            //The following catch statements will catch and handle different 
            //exceptions thrown by either Ranorex or the application while
            //executing the Ranorex class/function
            catch (ImageNotFoundException e)
            {
                Report.Error(e.ToString());
                Report.LogData(ReportLevel.Error, "Image not found", e.Feature);
                Report.LogData(ReportLevel.Error, "Searched image", e.Image);
                Report.End();
                HandleError();
            }
            catch (RanorexException e)
            {
                Report.Error(e.InnerException.Message.ToString());
                Report.End();
                HandleError();
            }
            
            catch (ThreadAbortException)
            {
                Report.Warn("AbortKey has been pressed");
                Thread.ResetAbort();
                Report.End();
                HandleError();

            }
            catch (Exception e)
            {
                Report.Error("Unexpected exception occured: " + e.ToString());
                Report.End();
                HandleError();
            }

Code: Select all

 [Serializable]
        public class PRTestingWithLinearStagePart3wFail : RanorexTest
        {
            public override void RanorexStart()
            {
                base.Name = "PRTestingWithLinearStagePart3 w/ Fail"; //Sets name for TE TestSequence
                AutomateXYprStagePart3_w_fail.Start();
            }
        }

When I run the test in Ranorex Studio its ok. When call the function in my app via the Start, it causes a crash.

The crash happens when the validation does not pass and continue on fail is set to false.

Thanks for the help in advance
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Module error is causing calling app to crash

Post by Support Team » Fri Jul 08, 2011 10:11 am

Hi,

Would it be possible to send ([email protected]) or post us your whole project where the crash occurs? Because with a small snippet of your code it is hard to find the error.
Did you try to place try catches over each method where the error can be thrown? You said, in Ranorex Studio it is working as expected. Please try to compare you code and the code of Ranorex Studio, maybe you can narrow down the issue in that way.

Regards,
Peter
Ranorex Team

SeanP
Posts: 60
Joined: Wed Sep 01, 2010 11:48 pm
Location: Irvine California

Re: Module error is causing calling app to crash

Post by SeanP » Fri Jul 08, 2011 5:04 pm

Support Team wrote:Hi,

Would it be possible to send ([email protected]) or post us your whole project where the crash occurs? Because with a small snippet of your code it is hard to find the error.
Did you try to place try catches over each method where the error can be thrown? You said, in Ranorex Studio it is working as expected. Please try to compare you code and the code of Ranorex Studio, maybe you can narrow down the issue in that way.

Regards,
Peter
Ranorex Team

I did a WinDiff on the files used and the files in Ranorex. and they are identical. I even tried copying them immediately after they ran successfully in Studio.

Let me see if I can sort out a way to send you the project it crashes in. Not sure if I am allow to. We made our own Test Suite software (before 3.0) and we use that since it also allows remoting to machines and a few other handy little features.

I have attached an image of where it fails the validation and crashes.

I have also posted the Ranorex Project. you will notice some minor changes to things such as namespace and what not. This is just to be more inline with our companies coding practices.
You do not have the required permissions to view the files attached to this post.

SeanP
Posts: 60
Joined: Wed Sep 01, 2010 11:48 pm
Location: Irvine California

Re: Module error is causing calling app to crash

Post by SeanP » Fri Jul 08, 2011 7:47 pm

I have written a small little app to test just this class.

I have wrapped it in the try catches and I still got an unhandled-exception/crash. This is when I have a general exception handler too.



This is what i did....

Code: Select all

        private void button1_Click(object sender, EventArgs ex)
        {

            try
            {
                AutomateXYpr3fail.Recording1.Start();
            }

           //The following catch statements will catch and handle different 
            //exceptions thrown by either Ranorex or the application while
            //executing the Ranorex class/function
            catch (ImageNotFoundException e)
            {
                Report.Error(e.ToString());
                Report.LogData(ReportLevel.Error, "Image not found", e.Feature);
                Report.LogData(ReportLevel.Error, "Searched image", e.Image);
                Report.End();
                MessageBox.Show("Image Exception caught   " + e.ToString());
            }
            catch (RanorexException e)
            {
                Report.Error(e.InnerException.Message.ToString());
                Report.End();
                MessageBox.Show("Ranorex Exception caught   " + e.ToString());
            }

            catch (Exception e)
            {
                Report.Error("Unexpected exception caught" + e.ToString());
                Report.End();
               
            }
            
        }

I used the attached files. I also included the exception message on the dump.
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Module error is causing calling app to crash

Post by Support Team » Mon Jul 11, 2011 10:27 am

Hi,

The InnerException can be null. Please use e.ToString() instead of your code and try it again.
Report.Error(e.InnerException.Message.ToString());
Regards,
Peter
Ranorex Team