C#: Using alternate web browser on Win Forms

trevor1940
trevor1940 used Ask the Experts™
on
Hi
I'm tryingg to build a winforms app that uses the built in web browser

On loading a JavaScript hungry HTML5  page I get a number of error boxes similar to the image

JSeror.JPG
Google suggested doing this which didn't work   (Even running the "...\debug\AppName.exe" in admin mode allowed the regestry to be set but failed to load the page correctly

More googling suggested using the nuget package Geckofx60.64


I'm struggling to know how to install this as there are several when searching for Geckofx

I'm also unsure how to run even the simple example given

 [STAThread]
       static void Main(string[] args)
       {
           Xpcom.Initialize("Firefox64");
           var geckoWebBrowser = new GeckoWebBrowser {Dock = DockStyle.Fill};
           Form f = new Form();
           f.Controls.Add(geckoWebBrowser);
           geckoWebBrowser.Navigate("www.google.com");
           Application.Run(f);
       }

Open in new window


Could someone start me of?

in my App I need to have real browser with at least 1 button that is used after the page loads to analyse the page using xpath queries
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Technical Specialist
Awarded 2017
Distinguished Expert 2018
Commented:
I recently used CefSharp after searching for a while for a proper alternative
https://cefsharp.github.io/

Author

Commented:
Hi

Could you give me a clue how to set this up?
Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018

Commented:
Download the sample project
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

David FavorFractional CTO
Distinguished Expert 2018

Commented:
The problem is your "built in web browser" has problems processing some or all Javascript.

CefSharp is more of a Windows specific (code will never run anywhere else) solution.

Use http://phantomjs.org/ if you'd like your code to run on any OS.

Author

Commented:
Downloaded Sample project
set CefSharp.Test as starup file
build caused a whole host of errors

"Severity      Code      Description      Project      File      Line      Suppression State
Error      CS0117      'TaskCreationOptions' does not contain a definition for 'RunContinuationsAsynchronously'      CefSharp.OffScreen.Example      D:\Vb\Test\CefSharp-master\CefSharp.OffScreen.Example\Program.cs      119      Active
"

have no clue what these mean or if i've done it wrong there dosn't seem to be an install guide

I'm unlikely to run this outside windows but will   try http://phantomjs.org/  tomorrow hopefully it will be a tad more straight forward
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Best to open a ticket with CefSharp or post to one of their user forums for assistance with this.

Author

Commented:
Hi
I managed to get this to work This Tutorial

For anyone else reading this where it said edit *.csproj and App.config files I did it with Visual Studio closed using an external xml / text editor
AT 2B I had to add new CPU and use  x86

Gave up on the download examples

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial