Closed wangwei18 closed 3 years ago
got this error when MS Access runs as administrator
tried #340 solution, no luck.
getting error at Await WebView21.EnsureCoreWebView2Async(webView2Environment)
@wangwei18 What user data folder are you using? If you are running from Program Files, you will need to specify a different user data folder when creating your environment.
@champnic , thanks for looking into this. I used the workaround mentioned in #340 to set temp directory to create env. my code is below. But for some reason, when MS Access runs access app that references this COM library, it still tries to write to Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE.WebView2\EBWebView folder. I can give Users group full access to the folder MSACCESS.EXE.WebView2 as my workaround.
Private Sub FormWebReceipting_Load(sender As Object, e As EventArgs) Handles Me.Load InitializeWebView2Async() End Sub
Private Async Sub InitializeWebView2Async(ByVal Optional tempDir As String = "")
Dim webView2Environment As CoreWebView2Environment = Nothing
Dim tempDir2 As String = tempDir
If String.IsNullOrEmpty(tempDir2) Then
tempDir2 = Path.GetTempPath()
End If
AddHandler WebView21.CoreWebView2InitializationCompleted, AddressOf WebView21_InitializationCompleted
Dim options As CoreWebView2EnvironmentOptions = Nothing
webView2Environment = Await CoreWebView2Environment.CreateAsync(Nothing, tempDir2, options)
Await WebView21.EnsureCoreWebView2Async(webView2Environment)
WebView21.Source = New Uri(RectURL, UriKind.Absolute)
End Sub
Private Sub WebView21_InitializationCompleted(ByVal sender As Object, ByVal e As EventArgs)
System.Diagnostics.Debug.Print("Info: WebView21_InitializationCompleted")
End Sub
If you debug your code, can you verify the value of 'tempDir2' before you use it to create the environment? The other thing to check is that the control hasn't already been initialized. When you create and add the WebView2 control to the form (may have been auto-generated by the designer) make sure it's not setting the Source there. Otherwise that will kickoff initialization and won't pickup the different directory.
during debug using a .net test project, value of "tempDir2" points to temp under my user id, it works as expected. but remember my real app is a MS access app that calls this .net COM library, I don't know there is a way to debug (I guess I can write to a log file). Yes, I commented out the link that set Source in designer code..
close since I am fine with giving users group write permission to Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE.WebView2\EBWebView folder
I have a .NET COM Class Library that is used by a MS ACCESS app. WebView2 is used by the .NET library. When library is used by a .NET WinForm app, WebView2 works fine. But when library is used by my MS Access app, WebView2 doesn't display anything, no exception raised either..