2

I am writing some code in Selenium C# and have encountered an issue I am having some trouble figuring out. I installed Selenium on a test machine and have it working with Firefox. I had an issue when the browser updated, but resolved it when I installed Selenium 3.0. I installed Selenium on my normal machine, where my Firefox version is 49.0.2 and it is throwing me the following error:

"An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll Additional information: The specified executable is not a valid application for this OS platform."

Has anyone encountered this before? The Operating Systems of the machines are both the same. I am wondering if I possibly installed something incorrectly. Thanks.

AndrewC10
  • 357
  • 1
  • 4
  • 20

1 Answers1

0

I should have added this in comment. But dont think it will fit there.

Basically win32 exception is not part of dotnet native exceptions. But dotnet provides mechanism to handle win32Execption. There are N number of Win32 exceptions, it is very difficult to trouble shoot unless you know the specific one.

You add "try .... catch" statement as shown below to your C# code. Then print the message. that gives you more information on what is going wrong

try {

//YOUR CODE / BUSINESS


   }
   catch(Win32Exception w)
 {

          Console.WriteLine(w.Message);
          Console.WriteLine(w.ErrorCode.ToString());
     }

Then if you can read message, you will know what is missing/happening.

My doubt is you are trying to access functionality from some executable or library, which does not exist on your system.

Add Namespace: System.ComponentModel.Win32Exception (I think you know it).

Pavan Chandaka
  • 11,671
  • 5
  • 26
  • 34
  • Thanks for the response. I have added the Try Catch and it moves the "The specified executable is not a valid application for this OS platform." to the console. Other than that it isn't telling me much. Not sure if it has something to do with a 32 vs 64 bit machine. – AndrewC10 Oct 26 '16 at 13:57
  • Hmm.. you can try some more and see. Add these two line in catch block and see if it is helping more Exception e=w.GetBaseException(); Console.WriteLine(e.Message); – Pavan Chandaka Oct 26 '16 at 20:14