Skip to content

[Problem/Bug]: Microsoft.Web.WebView2.Core.WebView2RuntimeNotFoundException  #4170

Open
@uhlrog

Description

@uhlrog

What happened?

I have get assignment to solve this :-)
We have implemented webview2 in 2 wpf:s and 2 winforms in a large old monolit with wpf:s and winforms. We use a lot of Citrix servers and our users use then Citrix Workspace when they run the application. On the citrix servers version 109.0.1518.140 is installed. SDK is 1.0.1108.44. But what I have read, sdk will be forward-compatible.

Works pretty well but quite often they get Microsoft.Web.WebView2.Core.WebView2RuntimeNotFoundException: Couldn't find a compatible Webview2 Runtime installation to host WebViews. ---> System.IO.FileNotFoundException

It works for a while and suddenly they get the above exception and then need to restart the application to get it to work again.

The wpf pages we have implemented like this

<wv2:WebView2 Grid.Row="0" x:Name="webView" />

private readonly string _userDataFolder = Path.GetTempPath() + "cache\\" + Shared.User.Controller.CurrentUser.UserName.ToLower();
.
.
var env = await CoreWebView2Environment.CreateAsync(userDataFolder: _userDataFolder);
await webView.EnsureCoreWebView2Async(env);

Winforms implemented
Designer file

Me.WebView = New Microsoft.Web.WebView2.WinForms.WebView2()
Friend WithEvents WebView As Microsoft.Web.WebView2.WinForms.WebView2

Code file

Dim strFileAsset = "TempFiles"
Dim strFileTempfolder = System.IO.Path.GetTempPath
Dim strUserDataFolder As string = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "OMS", "WebView", "DM")
webView2Environment = CoreWebView2Environment.CreateAsync(Nothing, strUserDataFolder).Result
Await WebView.EnsureCoreWebView2Async(webView2Environment)
WebView.CoreWebView2.SetVirtualHostNameToFolderMapping(strFileAsset, strFileTempfolder, CoreWebView2HostResourceAccessKind.Allow)  

Is there any obvoius we are doing wrong? Why is the file suddenly gone?

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

109.0.1518.140

SDK Version

1.0.1108.44

Framework

WPF

Operating System

Windows Server

OS Version

6.3.9600 Build 9600 Microsoft Server 2012 R2 Standard

Repro steps

See my question above

Regression

No, this never worked

Last working version (if regression)

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions