Use chrome as browser in C#?

前端 未结 10 2119
栀梦
栀梦 2020-12-02 10:51

Is there a way to use Google Chrome (or Safari or Firefox) as the browser in a C# application? C# now uses Internet Explorer, and the website they want to use in this progra

相关标签:
10条回答
  • 2020-12-02 11:50

    Update 2016:

    Unfortunately most of the above solutions are out of date and no longer maintained.

    There are 3 additional options I can suggest that are still actively developed:

    1. BrowseEmAll.Cef

    A .Net component that can be used to integrate the Chrome engine into your .Net Application. Based on CefGlue but a little faster on updates to the latest Chrome version. Also there is a commercial support option available which might come in handy for some. Of course the component itself is open source.

    2. BrowseEmAll.Gecko

    Another .Net component which can be used to integrate the Firefox engine into your .Net application. This is based on Geckofx but unlike the current version of Geckofx this will work with a normal release build of Firefox. To use Geckofx you will need to build Firefox yourself. Again commercial support is available but the component itself is fully open source.

    3. BrowseEmAll Core API

    Need all the different browsers in your .Net Application? Which the BrowseEmAll Core API you can integrate Chrome, Firefox, Webkit and Internet Explorer into your application. This is a commercial product though so be warned.

    (Full disclosure: I work for this company so take everything I say with a grain of salt)

    0 讨论(0)
  • 2020-12-02 11:51

    Take a look at the DotNetBrowser library. It provides Chromium-based WPF and WinForms browser controls, which are quite easy to embed into .NET application. It supports all the modern web standards including HTML5, CSS3 and JavaScript. The rendered page looks exactly like in Google Chrome.

    The library inherits Chromium's multi-process architecture – each web page is rendered in a separate Chromium process, and the application will continue working even after plugin crash or any other unexpected error occurs on the web page.

    Here are some other useful features, provided by DotNetBrowser: it is possible to listen to load events, handle network activity, configure proxy, simulate user actions, work with cookies, access and modify DOM, listen to DOM events, call JavaScript from .NET and vice versa, use web camera and microphone on the web page, set up WebRTC-based communication, and more.

    Check out the API Reference for more details.

    The code snippet below demonstrates how to create a BrowserView, embed it into a Form, and load a URL:

    using System.Windows.Forms;
    using DotNetBrowser;
    using DotNetBrowser.WinForms;
    
    namespace WinForms.DotNetBrowser
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                BrowserView browserView = new WinFormsBrowserView();
                Controls.Add((Control) browserView);
                browserView.Browser.LoadURL("http://www.youtube.com");
            }
        }
    }
    

    Once you run the example above you will get the following output:

    The library is commercial. Commercial licenses include support packages for different team sizes. It is also possible to purchase the library’s source code.

    Besides its own page the component is available as NuGet package and as VSIX package in the Visual Studio Marketplace.

    0 讨论(0)
  • 2020-12-02 11:54

    You can use WebKit.NET. This is a C# wrapper for WebKit, which is the rendering engine used by Chrome.

    0 讨论(0)
  • 2020-12-02 11:54

    Try this: http://code.google.com/p/geckofx/

    0 讨论(0)
提交回复
热议问题