Windows

Cross-platform

Quick start for console application

This guide shows how to start working with DotNetBrowser and embed it in a simple console application.

Before you begin make sure that your system meets software and hardware requirements.

1. Create a .NET console application

Open the Terminal or Command Line prompt, navigate to the necessary directory and run the following command:

dotnet new console -o Example.Console

The project will be created in the folder Example.Console.

2. Add DotNetBrowser package

Change directory to Example.Console and add the required package for your OS:

Windows:

dotnet add package DotNetBrowser

Linux x64:

dotnet add package DotNetBrowser.Linux-x64

Linux ARM64:

dotnet add package DotNetBrowser.Linux-arm64

macOS x64:

dotnet add package DotNetBrowser.macOS-x64

macOS ARM64:

dotnet add package DotNetBrowser.macOS-arm64

Cross-platform:

dotnet add package DotNetBrowser.CrossPlatform

3. Change source code

Insert the following code using any text editor into the Program.cs Program.vb file:

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

namespace Example.Console
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            EngineOptions.Builder builder = new EngineOptions.Builder();
            // Uncomment the line below to specify your license key
            // builder.LicenseKey = "your_license_key";

            using (IEngine engine = EngineFactory.Create(builder.Build()))
            {
                IBrowser browser = engine.CreateBrowser();
                browser.Navigation
                       .LoadUrl("https://html5test.com/").Wait();
                string title = browser.Title;
                System.Console.WriteLine($"Web page title: {title}");
            }
        }
    }
}
Imports System
Imports DotNetBrowser.Browser
Imports DotNetBrowser.Engine

Namespace Example.Console
	Friend Class Program
		Public Shared Sub Main(args() As String)
		    Dim builder = new EngineOptions.Builder()
		    ' Uncomment the line below to specify your license key
		    ' builder.LicenseKey = "your_license_key"

			Using engine As IEngine = EngineFactory.Create(builder.Build())
				Dim browser As IBrowser = engine.CreateBrowser()
				browser.Navigation _
				       .LoadUrl("https://html5test.com/").Wait()
			    Dim title = browser.Title
			    System.Console.WriteLine($"Web page title: {title}")
			End Using
		End Sub
	End Class
End Namespace

4. Get trial license

To get a free 30-day trial license, fill in the web form and click the GET MY FREE TRIAL button. You will receive an email with the license key.

5. Add a license

To embed the license key into your project, copy the license key string from the email and insert it as shown below:

EngineOptions.Builder builder = new EngineOptions.Builder();
// Uncomment the line below to specify your license key
builder.LicenseKey = "your_license_key";
Dim builder = new EngineOptions.Builder()
' Uncomment the line below to specify your license key
builder.LicenseKey = "your_license_key"

For more information on license installation, refer to this article.

6. Run the application

To launch application, use:

dotnet run

Console

Go Top