question

ThadThorpe-8934 avatar image
0 Votes"
ThadThorpe-8934 asked Elias-0405 edited

webview2/c# problem with exiting webview2 window.

Recently, I put together C# and webview2 mix , to access some web pages from a c# program, and the end results were quite nice; a working c#/webview2 webpage window. It was just a simple, barebones approach. And it did not return any errors. But the problems came when I exited out of the webview2 window under the C# procedure and returned control back to the calling form/procedure_call. When the calling control was returned, the current form was overlayed by the webview2 webpage window - it was still waiting to be used - it didn't delete! There was nothing that could be done to terminate the window inside, so the process had to be manually terminated. What else needs to be done to exit out of the webview2 window seemlessly? It's just a simple approach, and I am not well versed in webview2 tools. What else do I need to incorporate into the c#/webview2 program to make it work the way I want it to be? Any help sure would be Great! Thanks in advance.
I'm using MSVC 2017.

dotnet-csharp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ThadThorpe-8934 ,
In order to find out the cause of the problem more accurately, please provide some code to reproduce the situation.
Best Regards,
Daniel Zhang

0 Votes 0 ·
Castorix31 avatar image
0 Votes"
Castorix31 answered

I followed the MSDN tutorial (Getting started with WebView2 in Windows Forms) and it works fine for me
Windows 10, VS 2019, WebView2 Runtime installed)


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Elias-0405 avatar image
0 Votes"
Elias-0405 answered Elias-0405 edited

I have the same problem.
To reproduce the problem, all you need to do is call a popup frame window containing a WebView2. When you close the popup frame window, you will see that the WebView2 is hanging and waiting to be closed manually. There is no way to close it until you exit your application. The workaround is to call the Hide method on FormClosed.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.