Search code examples
delphic++buildertedgebrowser

TEdgeBrowser Canary requirement


I tested TEdgeBrowser in RAD Studio 10.4.2 Sydney. Dropping the component onto a Form in C++Builder and then calling:

EdgeBrowser1->Navigate("https://www.stackoverflow.com/");

This results in an error on my development machine:

Failed to find an installed WebView2 runtime or non-stable Microsoft Edge installation.

I have placed WebView2Loader.dll (from C:\Program Files (x86)\Embarcadero\Studio\21.0\Redist\win32\) into the project's executable folder, so that could not have been the cause of the error.

After that, I installed Edge Canary, and then it started working without errors.

However, if I compile the same project in Release configuration, and then run on another system which only has a stable installation of the Microsoft Edge browser and doesn't have Edge Canary installed, it all works.

But, if I run the same Release build on my build system, it fails to load (probably because of the same reason as the Debug build - it can't find the Canary installation).

I tested TMS's TAdvWebBrowser component, which doesn't have this requirement, and it works on both systems without installing Edge Canary. But I'd prefer to use TEdgeBrowser instead, to avoid an unnecessary dependency on a third party component.

What is the reason for this odd behavior for TEdgeBrowser, and does the same happen in RAD Studio 11 Alexandria? Can this be avoided so it works with a stable Edge installation on both systems?

EDIT: I later discovered that there is this property:

EdgeBrowser1->BrowserExecutableFolder = "C:\\Program Files (x86)\\Microsoft\\EdgeCore\\101.0.1210.53";

With that, all works. But, according to the documentation (Using TEdgeBrowser Component and Changes to the TWebBrowser Component), it should automatically locate the current version of the WebView2 control on the system. It does this on one system, but not on the development system.


Solution

  • TEdgeBrowser requires WebView2 Runtime in order to operate. More details on MS Edge Documentation website.

    WebView2Loader.dll should be loadable by your application, in the same folder, known path or registered in path environment variable. Latest version is available on NuGet. Nupkg is a zip archive. Look in build\native\ folder.

    TEdgeBrowser.BrowserExecutableFolder should point to WebView2 runtime folder in case of fixed version.

    Fixed version distribution, placed inside your application folder seems the preferred way on your scenario.

    MS claims that evergreen version will be distributed by default in next Windows versions.