简体   繁体   中英

Selenium C# System.ComponentModel.Win32Exception' occurred in System.dll Error

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM