Page 1 of 1

Report not displayed after "OK" in ShowDialog

Posted: Fri Nov 05, 2010 3:15 pm
by CreeTar
A OpenFileDialog is displayed, if you abort the dialog, the report is shown.
If you do not abort the dialog and select a file then press ok, the report is NOT shown.

Why is that?

Code: Select all

			// create new dialog
			OpenFileDialog objOpenFileDialog = new OpenFileDialog();
			// set filter settings for the dialog
			objOpenFileDialog.Filter = "Executables (*.exe)|*.exe";
			// show dialog
			DialogResult objFileSelect = objOpenFileDialog.ShowDialog();
			// clean up
			objOpenFileDialog.Dispose();
			// debug message for report
			Report.Info("Script","done");

Re: Report not displayed after "OK" in ShowDialog

Posted: Mon Nov 08, 2010 10:49 am
by Support Team
Hi,

Sorry but I have no clue what you mean with your questions. Are you creating an own file dialog to open the report files of Ranorex or are you using the ReportViewer of Ranorex?

Regards,
Peter
Ranorex Team

Re: Report not displayed after "OK" in ShowDialog

Posted: Mon Nov 08, 2010 12:02 pm
by CreeTar
I am using the report functionality of Ranorex.
But if I display the OpenFileDialog(), the Report is not displayed anymore after the execution of the script.
If I just comment the ShowDialog() line, the report is displayed. I am not trying to open any file from Ranorex, I simply give the user a dialog to select a file, but I do not understand why Ranorex behaves like this, that's what I am trying to understand.

Re: Report not displayed after "OK" in ShowDialog

Posted: Mon Nov 08, 2010 1:30 pm
by Support Team
Hi,

It works when you cancel the dialog, because the working directory is not set. When you click open, the Dialog set the working directory to the new one (where the selected file is nested) and therefore the report cannot be written successfully. If you set following property to true it should work, even if you press the open button on the dialog.
objOpenFileDialog.RestoreDirectory = true;
Regards,
Peter
Ranorex Team

Re: Report not displayed after "OK" in ShowDialog

Posted: Tue Nov 16, 2010 12:34 pm
by CreeTar
Thanks a lot, it works, though i don't understand why the reporting is affected by a simple FileOpen-Dialog. Never saw anything like that in any other tool :(

btw. is there any way to abort the whole recording if an error has occured, cause if no file was selected, there is no point of continuing. I tried Application.Exit, but has no effect.

Regards and Thanks for your time.
Alex

Re: Report not displayed after "OK" in ShowDialog

Posted: Tue Nov 16, 2010 1:20 pm
by Support Team
Hi,

the only way to stop your recording is to throw an exception.
As you see in your Program.cs there is a try/catch block surrounding the execution of your recording.
Your code should look something like this:
...
if (objFileSelect != DialogResult.OK)
{
	throw new Exception("NoFileSelectedException");
}
...
Regards,
Tobias
Ranorex Team