MicrosoftEdge / MicrosoftEdge/WebView2Feedback

WebView2 was already initialized with a different CoreWebView2Environment. Check to see if the Source property was already set or EnsureCoreWebView2Async was previously called with different values.

Open
#2,435 7 comments 0 reactions 1 assignee View on GitHub

@david-risney is already working on this.

Since May 9, 2022.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description
Using Webview in wpf application to load google map in webview2. multiple Users are accessing this application from multiple client terminal so we are creating separate work environment for each user/client.

There is no issue on 1.0.961.33 SDK package however SDK: 1.0.1108.44 throws below exception.

  • $exception {"WebView2 was already initialized with a different CoreWebView2Environment. Check to see if the Source property was already set or EnsureCoreWebView2Async was previously called with different values."} System.ArgumentException

.XAML code:

.Xaml.cs code:

private async void InitializeAsync()
{
var filePath = Environment.UserName + "\" + Environment.GetEnvironmentVariable("CLIENTNAME");
var webView2Environment = await CoreWebView2Environment.CreateAsync(null, filePath);
await GoogleWebBrowser.EnsureCoreWebView2Async(webView2Environment);
AddHostObject();
}

Event Helper:

var filePath = Environment.UserName + "\" + Environment.GetEnvironmentVariable("CLIENTNAME");
var webView2Environment = await CoreWebView2Environment.CreateAsync(null, filePath);
await browser.EnsureCoreWebView2Async(webView2Environment);
browser.CoreWebView2.Navigate(strURI);

Getting exception on this line await GoogleWebBrowser.EnsureCoreWebView2Async(webView2Environment)

  • $exception {"WebView2 was already initialized with a different CoreWebView2Environment. Check to see if the Source property was already set or EnsureCoreWebView2Async was previously called with different values."} System.ArgumentException

Version
SDK: 1.0.1108.44
Runtime:
Framework: WPF
OS: Win10, Win7

I guess issue is in EnsureCoreWebView2Async function while comparing environment instances.

Please suggest any solution. also suggest ( if any) solution so that we don't have to create multiple environment for multiple user.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.