Does anybody happen to know if it is possible to develop a .NET based desktop app in Visual Studio with HTML5 as a front-end?
I know the answer on MSDN a couple of years back seemed to be no, but I'm wondering if there has been any change.
I know you can develop JavaScript based desktop apps with things like Chrome Apps, but I'm wondering if you can do the whole thing (except for the UI) in .NET in Visual Studio. I'm also aware I could code it all in JavaScript and talk to .NET web services, but again I just want it all in the desktop app.
You can use DotNetBrowser library to use HTML5 in .NET desktop applications.
The library provides a Chromium-based WPF component that can be embedded into your .NET application. The component supports calling JavaScript from C# and vice versa. Chromium engine will act as a HTML5 interpreter in this case.
Here's code example that demonstrates how to load HTML into the component and get HTML of the loaded web page:
using System;
using DotNetBrowser;
namespace MyNamespace
{
class Program
{
static void Main(string[] args)
{
// Provide path to the directory with DotNetBrowser Chromium binaries.
Environment.SetEnvironmentVariable("DOTNETBROWSER_BIN_DIR", @"D:\Library\Chromium");
// Create Browser instance.
Browser browser = BrowserFactory.Create();
// Register frame loading event listener.
browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
{
// Wait until main document of the web page is loaded completely.
if (e.IsMainFrame)
{
// Get HTML of the loaded web page and write it to Console.
Console.Out.WriteLine(e.Browser.GetHTML());
}
}
// Load HTML content from string .
browser.LoadHTML("<html><body><h2>Hello World!</h2></body></html>");
// Load google.com to get its HTML content.
browser.LoadURL("http://www.google.com");
}
}
}
To find out how to configure MS Visual Studio 2013 Project with DotNetBrowser you can take a look at Quick Start Guide.
It's free for Open-Source projects ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With