Report not displayed after "OK" in ShowDialog

Ask general questions here.
CreeTar
Certified Professional
Certified Professional
Posts: 13
Joined: Thu May 20, 2010 12:08 pm

Report not displayed after "OK" in ShowDialog

Post by CreeTar » Fri Nov 05, 2010 3:15 pm

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");

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Report not displayed after "OK" in ShowDialog

Post by Support Team » Mon Nov 08, 2010 10:49 am

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
.
Image

CreeTar
Certified Professional
Certified Professional
Posts: 13
Joined: Thu May 20, 2010 12:08 pm

Re: Report not displayed after "OK" in ShowDialog

Post by CreeTar » Mon Nov 08, 2010 12:02 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Report not displayed after "OK" in ShowDialog

Post by Support Team » Mon Nov 08, 2010 1:30 pm

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
.
Image

CreeTar
Certified Professional
Certified Professional
Posts: 13
Joined: Thu May 20, 2010 12:08 pm

Re: Report not displayed after "OK" in ShowDialog

Post by CreeTar » Tue Nov 16, 2010 12:34 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Report not displayed after "OK" in ShowDialog

Post by Support Team » Tue Nov 16, 2010 1:20 pm

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
.
Image