6

we trying to use WebView2 without WebView2 Runtime (because of it´s 100 MB size and distributing it to clients).

It was tested on 2 PC´s. Both of them have same version of Edge. On PC1 WebView2 is not working whithout WV2 Runtime, on PC2 is working fine.

Do you have please any clue where can be a problem, why on PC1 is not WebView2 working? (PC1 is used for programming, PC2 no).

Thank you

Dávid Šilon
  • 126
  • 1
  • 5
  • Which version of Edge browser are you using on the two machines? Does there any error show when WebView2 not working? Besides, it is recommended to use WebView2 Runtime instead of taking a dependency on the browser. *In the future, the Evergreen WebView2 Runtime plans to ship with future releases of Windows. Deploy the Runtime with your production app until the Runtime becomes more universally available.* For more information, you can refer to [this doc](https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#understanding-the-webview2-runtime). – Yu Zhou Jul 16 '21 at 05:25
  • Version of Edge on both machines is 91.0.864.67. On machine where WebView2 is not working there are no error, first (Microsoft welcome) page is just not showing. If WebView2 Runtime will be default program on Windows it would be perfect, unfortunately today we are not allow to distribute such massive app to the clients (in comparation with size of our app). – Dávid Šilon Jul 28 '21 at 09:23
  • 2
    If you don't use WebView2 Runtime, you need to install any [Insider (non-stable) Microsoft Edge (Chromium) browser channel](https://www.microsoftedgeinsider.com/en-us/download). The Microsoft Edge Stable channel is unavailable for WebView2 usage. I suspect that the working machine has Edge Insider channel installed which makes WebView2 working. – Yu Zhou Jul 29 '21 at 09:53
  • Yes, the WebView2 runtime is required for WebView to work (with the special exception noted by Yu Zhou above). – O'Rooney Dec 01 '21 at 20:13

3 Answers3

4

You can use a fixed Version of WebView2 and by this make sure that your programm works on every PC even if they dont have the runtime installed.

Here you can download the fixed version you prefer:

https://developer.microsoft.com/de-de/microsoft-edge/webview2/

After you downloaded it you need to decompress the file into a folder of your choice. You can do this with the command-line command:

expand {path to the package} -F:* {path to the destination folder}

Now you should have a folder with an executable runtime for WebView2. With the following code you can say where the path of this "executable folder" is.

var webViewEnvironment = await Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateAsync("Path of the executable folder"), ("Path where you want the Cache to be saved")));
await webView2.EnsureCoreWebView2Async(webViewEnvironment);

With this you don't need to install the WebView2 Runtime

NoahDr
  • 41
  • 4
  • When my path to "Path of the executable folder" is on a server/shared folder, the webview does not show (no errors, just nothing happens). When "Path of the executable folder" is on my local computer it works fine. Any idea how I can get it to work from path on a server/shared folder? – kazyama Aug 02 '22 at 11:12
3

The runtime is required for WebView2 (with the special exception that insider builds of Edge will provide it). So the answer is that you cannot use WebView2 without the WebView2 Runtime.

O'Rooney
  • 2,878
  • 2
  • 27
  • 41
1

To run any WebView2 based applications pre-requisite is to have WebView2 Runtime available on the host machine.

There are two possibilities of running a WebView2 based application enter image description here

So for your question

Do you have please any clue where can be a problem, why on PC1 is not WebView2 working? (PC1 is used for programming, PC2 no).

There could be a possibility that Evergreen WebView2 Runtime would already be present on host system (Where app runs).

Also related to availability of Evergreen WebView2 runtime -

In June 2022, Microsoft announced that it would make the WebView2 runtime available to all Windows 10 devices running at least April 2018 updates.

So if you have Windows 10 with 2018 updates or Windows 11 you would be having evergreen WebView2 runtime present.

Advice: To be sure that your application runs on systems not having Evergreen WebView2 runtime already installed

  1. supply fixed runtime along with your applications as extra payload.
  2. Use webview2 installer during the application start after checking WebView2 runtime availability ( would require elevated privileges )
WitVault
  • 23,445
  • 19
  • 103
  • 133