Home > Net >  Winforms WebView2 with fixed runtime not working from shared folder
Winforms WebView2 with fixed runtime not working from shared folder

Time:08-09

I'm using a fixed version of WebView2 runtime like described in WebView2 working without WebView2 Runtime.

When I save this fixed runtime folder on my local machine it works fine. But as soon as I try to access the exact same folder on a shared folder/server it does not work. Any ideas?

    public Form1()
    {
        InitializeComponent();
        this.InitWeb();
    }

    public async void InitWeb()
    {

        var webEnv = await CoreWebView2Environment.CreateAsync(@"\\SharedFolder\FixedVersionFolder", Path.GetTempPath());
        //var webEnv = await CoreWebView2Environment.CreateAsync(@"C:\FixedVersionFolder", Path.GetTempPath());
        await this.webView21.EnsureCoreWebView2Async(webEnv);

        webView21.Source = new Uri("https://www.microsoft.com");
    }

In this case the webview does not show but if I replace the webEnv init line with the commented one, which points to my local folder it works just fine. I have tried multiple shared folders including creating one on my computer and it does not work.

CodePudding user response:

The solution that worked for me was setting the WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS to --no-sandbox before the initialization of webview. I'm aware that this can cause some security risk, so use at your own risk.

Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--no-sandbox");
  • Related