MicrosoftEdge/WebView2Feedback

[Problem/Bug]: Webview2 not initialised 0x8007139F

MLammerS3 opened this issue · 1 comments

What happened?

A few of our customers complain about Webview2 not initialising.

The group or resource is not in the correct state to perform the requested operation. (Ausnahme von HRESULT: 0x8007139F) Inner:
bei System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
bei Microsoft.Web.WebView2.Core.CoreWebView2Environment.d__102.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
bei Microsoft.Web.WebView2.WinForms.WebView2.d__25.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei EFormGUI.eFormAnzeige.VB$StateMachine_88_Load_Async.MoveNext()

I tried adding a custom UserDataFolder, but still doesn't work.

Try
    If Not My.Computer.FileSystem.DirectoryExists(_Comhub.Local & "eFormularGUI\Webview") Then My.Computer.FileSystem.CreateDirectory(_Comhub.Local & "eFormularGUI\Webview")

    HTMLAnzeige.CreationProperties = New Microsoft.Web.WebView2.WinForms.CoreWebView2CreationProperties()
    HTMLAnzeige.CreationProperties.UserDataFolder = _Comhub.Local & "eFormularGUI\Webview"

    Dim options As New CoreWebView2EnvironmentOptions() With {.ExclusiveUserDataFolderAccess = True}
    Dim environment = Await CoreWebView2Environment.CreateAsync(Nothing, _Comhub.Local & "eFormularGUI\Webview", options)

    TWEB = HTMLAnzeige.EnsureCoreWebView2Async(environment)
Catch ex As Exception
    MainLOG.WriteLOGExeption(ex, "Webview2 einrichten")
End Try

Fenster_einrichten()
Await TWEB

The Folder is empty, no EBWebView folder ist created.

No DPI FLAGS in registry ...\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers.

I used dbgview64
RecursiveDirectoryCreate( C:\ProgramData\mediDOK\mediDOK\WebView Userdata\EBWebView directory exists )
00000025 50.07269287 [7920] WebView2: Initialization failed due to incompatible environment configurations. Please check if there is already a WebView2 running with the same user data folder but different environment parameters.

It looks like my Webview2 is trying to use the Webview2 of mediDOK?
Many of our customers use mediDOK in addition to our application but only a few have this problem.
Whats happening? Why can't Webview2 be initialised?

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

131.0.2903.70

SDK Version

1.0.2903.40

Framework

Winforms

Operating System

Windows 10, Windows 11

OS Version

No response

Repro steps

Can't repro.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

Code for creating the Webview2 has changed a little bit.
Webview is now created at runtime. But still the same problem that it is not initialised.

HTMLAnzeige = New Microsoft.Web.WebView2.WinForms.WebView2

HTMLAnzeige.CreationProperties = New Microsoft.Web.WebView2.WinForms.CoreWebView2CreationProperties()
HTMLAnzeige.CreationProperties.UserDataFolder = _Comhub.Local & "eFormularGUI\Webview"

Dim options As New CoreWebView2EnvironmentOptions() With {.ExclusiveUserDataFolderAccess = True}
Dim environment = Await CoreWebView2Environment.CreateAsync(Nothing, _Comhub.Local & "eFormularGUI\Webview", options)

HTMLAnzeige.Dock = DockStyle.Fill
Me.Controls.Add(HTMLAnzeige)
HTMLAnzeige.BringToFront()

'MainLOG.WriteLOGLine($"Init Webview2: {HTMLAnzeige.CreationProperties.UserDataFolder}, {environment.UserDataFolder}, {environment.FailureReportFolderPath}")
Await HTMLAnzeige.EnsureCoreWebView2Async(environment)

I checked the UserDataFolder Paths before EnsureCoreWebView2Async
HTMLAnzeige.CreationProperties.UserDataFolder = "c:\S3WIN\eFormularGUI\Webview" (correct)
CoreWebView2Environment.UserDataFolder = "C:\ProgramData\mediDOK\mediDOK\WebView Userdata" (incorrect)