Error When Running Executable File

Ask general questions here.
costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Error When Running Executable File

Post by costamesakid » Fri Mar 19, 2010 6:08 pm

I set my Build Configuration to 'Release' and Rebuilt my Solution. I then was able to run the projects corresponding .exe file from the Release folder without any problems.

I then copied the entire Release folder to another computer with Ranorex installed and when I tried to run the .exe file Microsoft threw an error "...has encountered an error and needs to close".

What exactly is needed to run Ranorex .exe files on a system other than the system which the solution is built?

Thanks

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Error When Running Executable File

Post by Ciege » Fri Mar 19, 2010 7:16 pm

Can you run the exe from a command prompt to see if you can get more details about the error?

Do you have the same version of Ranorex DLLs on both machines?

Any machine difference? Different OS, different bit 32 vs 64?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Error When Running Executable File

Post by costamesakid » Fri Mar 19, 2010 9:49 pm

The machines are definitely the same and so is the version of Ranorex. I tried to run it in a command line earlier and from what I recall the error was regarding not being able to find RanorexCore.dll.

I will copy and paste the error message here next time I am at the office. Thanks for your help.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Error When Running Executable File

Post by Ciege » Fri Mar 19, 2010 9:54 pm

OK, send the exact error when you get a chance.

My guess is that the Ranorex dlls may not be the same version or are installed in a different location between computers. I have seen a similar message when I compiled a script on one machine with a particular version of the DLLs (2.1.x) then tried to run it on a machine with the 2.2 version of the DLLs. Ranorex installs 2.2 to a different location than 2.1.

Good luck...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Error When Running Executable File

Post by costamesakid » Sat Mar 20, 2010 2:45 am

Does it make a difference where I place my 'Release' folder after I copy it over to the other machine? Thanks

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

Re: Error When Running Executable File

Post by Support Team » Sun Mar 21, 2010 6:15 pm

costamesakid wrote:Does it make a difference where I place my 'Release' folder after I copy it over to the other machine?
No, that should not make a difference (unless you use relative file paths inside your Ranorex code).

Please, post the error message that shows when you run your Ranorex executable from the command line! Do you have a try-catch clause around your Ranorex automation code in the Main method?

Try running Ranorex Spy or Recorder. If these two application don't start either, please try to reinstall Ranorex using the "Ranorex-2.X.X.exe" or "setup.exe" file, respectively! Maybe you did install Ranorex using the MSI package and a prerequisite is missing.

Regards,
Alex
Ranorex Support Team

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Error When Running Executable File

Post by costamesakid » Tue Mar 23, 2010 8:20 pm

Looks like Ciege was correct with his 1st response. The development system was running 2.2.2 and the runner system was running 2.2.1. Took me a second to figure it out because with the runner license I couldnt load Ranorex studio and view the version in Help > About. Thanks

This topic can be closed, but I have a related question that should probably be its own post. Anyway, I have code that prompts the user for an IP address. If the user clicks Cancel on the input dialog I terminate the program using "Thread.CurrentThread.Abort();". However, when I build in release mode and run the exe file, if the user clicks Cancel the program terminates, but Microsoft throws its own error "...has encountered an error and needs to close". Any ideas? Thanks

x = Interaction.InputBox("Enter The IP Address of your TOAD1 Interface","SUT IP Address","",300,300);
if (x == "")
{
MessageBox.Show("No IP Address Entered for TOAD1 Interface - Terminating Program");
Thread.CurrentThread.Abort();
}

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

Re: Error When Running Executable File

Post by Support Team » Tue Mar 23, 2010 10:29 pm

Don't use Thread.Abort to end your program. As its documentation describes (see http://msdn.microsoft.com/en-us/library/ty8d3wta.aspx), this method throws a ThreadAbortException. If you do not catch that Exception, your program will close with an unhandled exception and Windows will show an error dialog.

Use Environment.Exit instead or simply return from the Main method of your application.

Regards,
Alex
Ranorex Support Team

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Error When Running Executable File

Post by costamesakid » Wed Mar 24, 2010 8:40 am

Environment.Exit(-1);

Worked great for me. Thanks for the help.