DEV Community

artydev
artydev

Posted on • Updated on

WebWindow a lighter alternative to Electron

If you want to develop console app with a WebUI in C#, give WebWindow a try

WebWindow

You can trim down the size of the app to nearly 30M (see my previous post).

Simply add WebWindow nuget package in your console app.

Here is an example where I embed a html file in a resource,
within a HelloWorldApp application

Beware, embeding scripts, does not meen they are not visible if you open the executable file with an editor...

using System.IO;
using System.Reflection;
using WebWindows;

namespace HelloWorldApp
{
    //https://stackoverflow.com/questions/3314140/how-to-read-embedded-resource-text-file
    class Program
    {
        static void Main(string[] args)
        {
            string result;
            var assembly = Assembly.GetExecutingAssembly();
            var resourceName = "HelloWorldApp.wwwroot.index.html";
            var window = new WebWindow("My first WebWindow app");
            var stream = assembly.GetManifestResourceStream(resourceName);
            using (StreamReader reader = new StreamReader(stream))
            {
                result = reader.ReadToEnd();
            }
            window.NavigateToString(result);
            window.WaitForExit();
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)