-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WPF WebView2 not working in WPF Library #970
Comments
Hey @triod315 - Can you share the code you wrote using |
Hi @champnic, thank you for your response, you can see my usage of public async void TryInitWebView2()
{
await webView.EnsureCoreWebView2Async();
} And I am trying to use this function in the console app static void Main(string[] args)
{
WpfLibrary.TestWindow testWindow = null;
Thread thread = new Thread(()=> {
testWindow = new WpfLibrary.TestWindow();
testWindow.TryInitWebView2();
testWindow.ShowDialog();
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
} After that, I got an error, described above. |
Thanks for the added info. I've added this bug to our backlog to take a look! |
I have same problem. It works fine if windows class in same assembly as Main (startup project). But it throw if it is in other assembly. |
I Have Same Problem Too. I can use Winforms to Work WebView2,But WPF is blank..... |
Hi @triod315 -- I strongly suspect that you have the same problem as #1577, which is that your WebView2 control is trying to initialize before your app's event loop is running. See my comment on that thread for additional details and a potential workaround. Perhaps there's another possible workaround for you that involves using |
Hi @GihanSoft -- There are a couple of issues that can often appear as though the problem is that the WebView2-related window is in a library assembly rather than the app's assembly. Two such issues are discussed in #730 and #1418. Take a look through those discussions and see if either of them might apply to your situation. |
Hi @jackyg2jpd93 -- Unfortunately "WebView2 control is blank" can indicate a wide variety of potential issues. Calling |
This should be fixed now (as of a while ago). If you are still seeing this problem please let me know and what versions you are using. Thanks! |
Description
I have .net core 3.1 console application that uses WPF library. This library has a window with WebView.
I am trying to use this window in my console app:
And after start WebView2 shows a blank page instead of "https://www.microsoft.com" which written in Source. Also, I tried to create a window using System.Windows.Application instance, but got the same problem.
To resolve this problem I tried to use
EnsureCoreWebView2Async()
to initialize CoreWebView2 but got next ErrorVersion
Microsoft.Web.WebView2: 1.0.705.50
Runtime: Edge Canary 90.0.803.0
Framework: WPF .Net Core 3.1
OS: Windows 10 version 2004, os build 19041.804
Additional context
This problem only in WebView in WPF. With WinForms all works fine. Also, this problem appears only if a window created in a new STA thread (like in code examle).
Repository with example
AB#32059542
The text was updated successfully, but these errors were encountered: