DotNetBrowser

From Wikipedia, the free encyclopedia
DotNetBrowser
Developer(s)TeamDev
Stable release
2.11 / 14 January, 2022
Written inC#, C++
Operating systemWindows
TypeFramework, Web browser
LicenseTeamDev.[1]
Websitehttps://www.teamdev.com/dotnetbrowser

DotNetBrowser is a proprietary .NET library that provides a Chromium-based engine which can be used to load and display web pages.[2] [3][4] It is developed and supported by TeamDev since 2015.

Features[]

Some main features are as follows:

  • Load and display the web page.
  • Embed a Chromium-based browser in a .NET desktop application as a WPF or Windows Forms control.[5]
  • Handle navigation and network events.
  • Access Document Object Model of the loaded web page.
  • Execute JavaScript on the loaded web page, inject .NET objects and call them from JavaScript[6][7][8]

Usage[]

Primary usage is embedding a browser into various .NET desktop applications and displaying the web pages.[9] DotNetBrowser can also be used as a headless browser.

Another known use-cases are creating web-based kiosk applications[10] and VSTO add-ins for Microsoft Office.[11]

More examples and use-cases are available in the DotNetBrowser Examples repository.

Example[]

WPF[]

XAML markup

<Window x:Class="Sample.Wpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:wpf="clr-namespace:DotNetBrowser.Wpf;assembly=DotNetBrowser.Wpf"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800" Closed="MainWindow_OnClosed">
    <Grid>
        <wpf:BrowserView x:Name="browserView"/>
    </Grid>
</Window>

C#

using System;
using System.Windows
using DotNetBrowser.Browser;
using DotNetBrowser.Engine;

namespace Sample.Wpf;

public partial class MainWindow : Window
{
    private readonly IEngine engine;
    private readonly IBrowser browser;
     
    public MainWindow()
    {
        InitializeComponent();
         
        // Create and initialize the IEngine
        engine = EngineFactory.Create();
         
        // Create the IBrowser
        browser = engine.CreateBrowser();
        browser.Navigation.LoadUrl("https://teamdev.com/dotnetbrowser");
         
        // Initialize the WPF BrowserView control
        browserView.InitializeFrom(browser);
    }
     
    private void MainWindow_OnClosed(object sender, EventArgs e)
    {
        browser.Dispose();
        engine.Dispose();
    }
}

Windows Forms[]

C#

using System;
using System.Windows.Forms;
using DotNetBrowser.Browser;
using DotNetBrowser.Engine;
using DotNetBrowser.WinForms;

namespace Sample.WinForms;

public partial class Form1 : Form
{
    private readonly IEngine engine;
    private readonly IBrowser browser;
     
    public Form1()
    {
        InitializeComponent();
         
        // Create and initialize the IEngine
        engine = EngineFactory.Create();
         
        // Create the Windows Forms BrowserView control
        BrowserView browserView = new BrowserView() {
            Dock = DockStyle.Fill
        };
         
        // Create the IBrowser
        browser = engine.CreateBrowser();
        browser.Navigation.LoadUrl("https://teamdev.com/dotnetbrowser");
         
        // Initialize the Windows Forms BrowserView control
        browserView.InitializeFrom(browser);
         
        // Add the BrowserView control to the Form
        Controls.Add(browserView);
        Closed += Form1Closed;
    }
     
    private void Form1Closed(object sender, EventArgs e)
    {
        browser.Dispose();
        engine.Dispose();
    }
}

See also[]

References[]

  1. ^ "DotNetBrowser Product Licence Agreement". TeamDev. TeamDev. Retrieved 12 March 2021.
  2. ^ "DotNetBrowser on StackOverflow". Retrieved 14 March 2021.
  3. ^ "DotNetBrowser on NuGet". Retrieved 14 March 2021.
  4. ^ "c # - i want to get location information with dotnetbrowser".
  5. ^ "Chromium Web Browser Control in .NET Applications". DZone.
  6. ^ "DotNetBrowser and invalid external method call".
  7. ^ "Using dotnetbrowser to call JavaScript function to c#".
  8. ^ "The mutual call between the JS code of the DotNetBrowser internal page and the external C# code".
  9. ^ "Creating an HTML UI for Desktop .NET Applications". InfoQ. InfoQ. Retrieved 12 March 2021.
  10. ^ Mihika Kapoor. "Frame Building with C# and VB.NET". medium.com. Retrieved 17 May 2021.
  11. ^ "Using VSTO to develop Word AddIn, is there a third-party kernel that can replace webbrowser?". Retrieved 21 May 2021.

External links[]

Retrieved from ""