I have been working on a project with selenium 2 webdriver for a few weeks.
I got to a milestone and decided to compile my project in release mode and test the executable.

Thing is, it crashes if I try to run it from the release folder (or anywhere else via double click) but works fine when I start it with F5 in either debug or release mode.

I'm unsure how to even start to debug this problem to be honest.

I get the windows message "seleniumtest.exe has stopped working" with the options to debug, search online for a solution, or close the program, none of which do absolutely anything at all except close the program.

I have selenium library linked and I'm importing some win32 functions such as FindWindow, SetParent, SetWindowLong, and MoveWindow.

Hoping someone can give me a hint on where to start, even correct web search terms as those I've tried only seem to bring up unrelated problems.

Thank you for taking the time to read.

I'm not familiar with this tool, but since it is generating binary executables my experience shows that when it works in debug mode but not production mode (segfaults, etc), it is due to the fact that debug mode pads arrays and such with extra memory. As a result, you might consider buffer overflows as a cause of this problem. IE, you need to analyze your code to see if you need buffer and array sizes to accomodate string terminator (null bytes) and similar.

Check your Active solution platform if it is compatible with your System type (e.g. 64-bit)

Thanks for replies guys, I have checked and it's correct x86 for my win 7 OS, and is targeted to .NET framework 3.5.

Are you running VS as an administrator? Try turning off UAC (under user accounts) before running your program and see if it works.

Hmm, I am not running VS as admin, but if I right click the file in bin folder and run as administrator, it works fine.

In C++ I can find a setting to make an app only require asinvoker, but I cannot seem to find that setting in VC#.

Thanks for the hint, I know I cannot have done something terribly wrong now :)

Here is the manifest file in the bin folder of project.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>

I don't get it.

Just to be clear, did you go through these steps?
your project properties >> publish >> installer path >> publish now >> run setup.

You can try adding an application manifest to your project (as in UAC Troubles above).

Click "Project" (in menu bar)
Select "Add New Item"
Select "Application Manifest File"
Click "Add"

Try changing:

<requestedExecutionLevel level="asInvoker" uiAccess="false" />


<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

If that doesn't work, you may also look into changing "uIAccess" from false to true.

Step 6: Create and Embed an Application Manifest (UAC)

uiAccess Values:

False: The application does not need to drive input to the user interface of another window on the desktop. Applications that are not providing accessibility should set this flag to false. Applications that are required to drive input to other windows on the desktop (on-screen keyboard, for example) should set this value to true.

True: The application is allowed to bypass user interface control levels to drive input to higher privilege windows on the desktop. This setting should only be used for user interface Assistive Technology applications.

*Note: Applications with the uiAccess flag set to true must be Authenticode signed to start properly. In addition, the application must reside in a protected location in the file system. \Program Files\ and \windows\system32\ *

Also, \Program Files (x86)

And from:
Windows Integrity Mechanism Design

By specifying UIAccess=”true” in the requestedPrivileges attribute, the application is stating a requirement to bypass UIPI restrictions on sending window messages across privilege levels. Windows Vista implements the following policy checks before starting an application with UIAccess privilege.

• The application must have a digital signature that can be verified using a digital certificate that chains up to a trusted root in the local machine Trusted Root Certification Authorities certificate store.

• The application must be installed in a local folder application directory that is writeable only by administrators, such as the Program Files directory. The allowed directories for UI automation applications are:
◦ %ProgramFiles% and its subdirectories.

◦ %WinDir% and its subdirectories, except a few subdirectories that are excluded because standard users have write access.

The %WinDir% subdirectories that are excluded subdirectories include:
• \Debug

• \PCHealth

• \Registration

• \System32\ccm

• \System32\com

• \System32\FxsTmp

• \System32\Spool

• \System32\Tasks

Some of the info above references Vista. That is when UAC was first introduced in the (non-server) Windows operating system.

Edited 2 Years Ago by cgeier

Just to be clear, did you go through these steps?
your project properties >> publish >> installer path >> publish now >> run setup.

No, I just Build -> Build solution.

Reading through the rest of these replies and links now.

Thank you all, I appreciate you taking the time.

Try the publish way, because in this way you can add everything your program needs to operate to the installer, in these 2 buttons

Thank's oussama_1.

Doing that appears to have solved the problem.

I was unable to determine what the problem actually was though.

Sorry about that, and thank's once again for the help.

This question has already been answered. Start a new discussion instead.