0

I have a Console-Application to automate a webbrowser with selenium. On my local machine everything works fine, but executing the .exe throws an error on the server.

I created the program as Release in Visual Studio and copied the whole folder to the server. Starting the .exe throws a Null Reference Exception. Please watch the picture below.

enter image description here

The Program references to the program.cs, but i thought the release-folder is working for itself?!

I have already tried to comment out everything in the Main, because the exception throws there.

Maybe my usings could be a problem?

    using OpenQA.Selenium;
    using OpenQA.Selenium.IE;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using OpenQA.Selenium.Support.UI;
    using System.Data.SqlClient;
    using System.Data;
    using AutoIt;
    using System.Windows.Forms;
    using OpenQA.Selenium.Interactions;

Do you know something about this Error?

The Real Error is the following, found by the comments below :)

enter image description here

Florian3007
  • 87
  • 14
  • 3
    What is on line 89 of Program.cs? – mikelegg Oct 23 '17 at 09:27
  • 1
    It is nothing to do with the using statements, it is being thrown by the code which is on line 89 of Progam.cs. The release folder does 'work by itself' but contain information to allow you to debug. – tolanj Oct 23 '17 at 09:28
  • When you got selenium locally - you had to run an installer for it which installed selenium framework in appropriate locations on OS. Or Was it a nuget? In first case - you will have to install same selenium package on server. – Prateek Shrivastava Oct 23 '17 at 09:28
  • Line 89: driver.Close(); I am closing the webbrowser there, but i think thus could be the right approach. Maybe the internet Explorer on the Server is not compatible with this code? (Same version "IE 11") – Florian3007 Oct 23 '17 at 09:34
  • @Prateek Shrivastava It was a nuget – Florian3007 Oct 23 '17 at 09:35
  • 1
    @Florian3007 - Null Reference means - one of the Object is Null. In your code try to scan for cases where you have something like: A.Method() or A.Property or A.B.Something() - where A & B are objects. One of these is staying as Null and you need to find which one is? If exception line is Driver.Close(); then driver object is null. Which would mean something is missing on server. Are you using Chrome/IE driver in the selenium automation. Is that browser installed on server? – Prateek Shrivastava Oct 23 '17 at 09:38
  • @Prateek Shrivastava I have a TryCatch before where the IE should be launched within the driver-object. The Browser never pops up, so the driver is null. The Internet Explorer Versions are completely identical (11.0.9600.18792) – Florian3007 Oct 23 '17 at 09:44
  • I'll remove the try catch and report you the real exception... Thanks for help btw. – Florian3007 Oct 23 '17 at 09:46
  • I am not sure why they mark it as a duplicated question! I agree that question title is duplicated but his problem is not the same. The issue here is that `exe` missed some assemblies when he tries to copy into different directory or machine. So he needs to merge exe along with dlls – Saif Oct 23 '17 at 09:48
  • Downvotes don't interest me actually, i just need to solve the problem. I added a picture where the real Error is shown – Florian3007 Oct 23 '17 at 09:51
  • 1
    @Florian3007: Does that latest error message not tell you exactly what the problem is and how to solve it? ie "Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones." – Chris Oct 23 '17 at 09:54
  • @Florian3007 you need to use `ILMerge` to combine and merge assemblies `dll` with `exe`. The program throws the exception because it didn't find `dll` that your code trying to use. Look at this link https://www.codeproject.com/Articles/17797/Gilma-GUI-for-the-ILMerge-Application-Revised-for – Saif Oct 23 '17 at 09:56
  • Yes im searching for the error. I Think i can solve it by myself at this point. Thanks to anyone :) – Florian3007 Oct 23 '17 at 09:57
  • IntroduceInstabilityByIgnoringProtectedModeSettings = true did it – Florian3007 Oct 23 '17 at 11:41

0 Answers0