0

I am unable to show more than one WebView2 control in an application hosted on a network shared folder.

Let me say straight out of the bat that the solutions disused here (including Microsoft article) do not work:

WebView2 Environment Exception (Requested resource is in use)

absolutely do not fix this issue.

The application binaries is hosted on a server, with multiple users launching the application from that single location. Once one user has WebView2 displayed, another user on the network gets the exception.

As you can see in the code snippet, I am creating subfolders for each users session (this has been tested as is working as expected) :

var dataFolder = @"\\someserver\SomeApplicationFolder";

var subfolder = Guid.NewGuid().ToString();

var di = Directory.CreateDirectory(Path.Combine(dataFolder, subfolder))

var fullpath = dataFolder + @"\\" + subfolder;

var env = await CoreWebView2Environment.CreateAsync(userDataFolder: fullpath);

await webView2ReportServer.EnsureCoreWebView2Async(env);

It possible the locks happen on files in the folder "MyApplication.exe.WebView2" which is in the applications binaries folder on the single network share. But I do not want to install the binaries on each individual client's PC as this is bad practice and not desired architecture.

John S
  • 71
  • 7
  • Different instances of WebView2 must use different UserDataFolder. They can not share the same. Then you get your exception. – Poul Bak Mar 02 '22 at 23:27
  • I would create the folders on the user's computer, like `App_Data\Local\YourCompanyName\WebView2` - that way all users have a unique environment. – Poul Bak Mar 02 '22 at 23:29
  • @PoulBak thanks but of course I already did this. These locks do not relate to the UserData folder. Something else is happening. When the application is executed from a directory on network server, WebView2 creates a directory "MyAppName.exe.WebView2" in that application folder. The locks relate to that folder. It seems WebView2 is simply incapable of being hosted as part of application that is hosted on a network folder and accessed by multiple users from client PC's. – John S Mar 04 '22 at 10:09

1 Answers1

-1

One way i found is to copy the exe file and run each of them on the different computers...

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 05 '22 at 10:00