-
Notifications
You must be signed in to change notification settings - Fork 51
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
Problem using pre-created environment with WinForms WebView2 control #177
Comments
Thanks for reporting this @ebriangast! Great issue. We'll look into how we might address this. |
@ebriangast thank you as I spent the last 2 hours wondering why this is not working. Same issue, my use case is a application that is being delivered via RemoteApp where each user has own directory, if source is set it will not be able to set the user directory. Comment out the source solves the issue. Thanks |
This should be fixed now - setting Source to about:blank should avoid the implicit initialization and this error. If you still see this please reopen. Thanks! |
Apologies, apparently we have a fix but it hasn't been committed yet. This should be fixed soon! |
We're making a change to the default behavior here so that the Source property doesn't get automatically set for Winforms. Instead the default is null, and the dev can choose to set Source if they want implicit initialization, or can manually create the environment and initialize explicitly. Additionally, we are adding a CoreWebView2CreationProperties like the existing WPF one, to allow easily setting the environment while still using the Source property. These changes will be coming in about 2 weeks. Thanks! |
This should be fixed in WebView2 SDK 1.0.674-prerelease. If this is still an issue please let us know. Thanks! |
I've followed the Getting Started with WebView2 in Windows Forms documentation and am now trying to extend the application to pre-create the CoreWebView2Environment with a specific user data folder.
It seems the setting of WebView2.Source in the designer generated code triggers the automatic initialization of the environment before I have a chance to call EnsureCoreWebView2Async to provide my own. I see this happen even with the WebView2 control Source property default value of "about:blank", and if I try to remove the value for the Source property in designer I get an error of "Property value is not valid."
Specifically, I added code to Main to create the environment and pass it to the Form constructor:
Then immediately called EnsureCoreWebView2Async after calling InitializeComponent:
And also set an appropriate default of addressBar.Text in the designer.
If I manually comment out the setting of webView.Source in the Designer.cs file this works, and the environment I constructed is used. But making additional changes in the designer reverts this change to the generated code.
AB#26434822
The text was updated successfully, but these errors were encountered: