Search code examples
delphimicrosoft-edgedelphi-10.4-sydneytedgebrowser

TEdgeBrowser Navigate fails with error "File not found"


My first attempt to try the new TEdgeBrowser fails with 'The system can't find the file'

procedure TFrmTEdgeBrowser.BtnNavigateClick(Sender: TObject);
var lErrCode: Integer;
begin
  if not EdgeBrowser.Navigate('https://www.google.com') then
  begin
     lErrCode := EdgeBrowser.LastErrorCode;
     ShowMessage(IntToStr(lErrCode) + ': ' + SysErrorMessage(lErrCode));
  end;
end;

Error code -2147024894 = $80070002 is indeed ERROR_FILE_NOT_FOUND

Sequence (e.g as per https://www.delphipraxis.net/204266-new-vcl-tedgebrowser-component-coming-rad-studio-10-4-a.html or http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_TEdgeBrowser_Component_and_Changes_to_the_TWebBrowser_Component):

  • New Win10 VM, start Edge, win installer runs and install Edge correctly
  • Download and install Edgeview2 SDK through GetIt
  • Copy c:\Program Files (x86)\Embarcadero\Studio\21.0\Redist\win32\WebView2Loader.dll to app dir

Config: Delphi 10.4.3 Sydney, running a 32 bit app in a Win10 VM, Edge 84.0.522.52 installed

Attempts: no https: in front, reboot, tried to get more info from a TApplicationEvents.OnException

I then tried to run the demo c:\Users\Public\Documents\Embarcadero\Studio\21.0\Samples\Object Pascal\VCL\WebBrowser\Edge\EdgeBrowser.dproj (with the dll copied into that directory as well) but this gives the initialization error from the end of its:

procedure TfrmMain.EdgeBrowserCreateWebViewCompleted(Sender: TCustomEdgeBrowser; AResult: HResult);
begin
{$IFDEF DEBUG}
  OutputDebugString('EdgeBrowser OnCreateWebViewCompleted');
{$ENDIF}
  if Succeeded(AResult) then
  begin
    tbCancel.Enabled := True;
    tbReload.Enabled := True;
    tbGo.Enabled := True;
    edtAddress.Enabled := True;
    Sender.AddWebResourceRequestedFilter('*', COREWEBVIEW2_WEB_RESOURCE_CONTEXT_IMAGE);
  end
  else
  begin
    if AResult = HResultFromWin32(ERROR_FILE_NOT_FOUND) then
      Application.MessageBox('Could not find Edge installation. ' +
        'Do you have a version installed that''s compatible with this WebView2 SDK version?',
        'Edge initialisation error', MB_OK or MB_ICONERROR)
    else
      Application.MessageBox('Failed to initialise Edge browser control',
        'Edge initialisation error', MB_OK or MB_ICONERROR)
  end;
end;

But now AResult is -2147467259 = $80004005
which seems to be data/ODBC related.

Updating to a later version 0.9.579 (20 jul 2020) of Microsoft.Web.Webview2 did not help.


Solution

  • I downloaded the Beta Version of Edge and that fixed it for me.

    I was using version 84.0.522.59 (Official build) (64-bit), and had the same problem as you.

    The version I downloaded was 85.0.564.30 (Official build) beta (64-bit).

    Also, I looked back over the documentation and it says to get the canary channel version. So while I downloaded the beta version, I'm assuming the canary version is what you are supposed to download, and will also fix the problem.

    http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_TEdgeBrowser_Component_and_Changes_to_the_TWebBrowser_Component

    The Microsoft Edge Chromium-based browser currently available from https://www.microsoftedgeinsider.com/download (Canary channel version whilst the WebView2 SDK is in pre-release, currently the minimum required version is 82.0.430.0).