-
Notifications
You must be signed in to change notification settings - Fork 55
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
Microsoft Edge can't read and write to its data directory #340
Comments
I now tried to change the userDataFolder like suggested here #324 (comment) but it had no effect at all :/
|
I created my WebView in Forms Designer. The
Can you suggest any best practice how to change the userDataFolder when the WebView was created in Forms Designer? |
There is an example here. The different versions of MS Edge that are installed can be found in The path to the "Edge\Application" folder can be found in the registry: However, the regular versionof MS Edge doesn't support WebView2 yet. So you have to use a canary/dev version. It looks like the canary/dev version of MS Edge, is in: You should be able to do something like the following. The name of the WebView2 control in the following code, is "webView2Ctl":
See #329 for more info. To see the version of MS Edge, go/navigate to "edge://version/" (ie: enter "edge://version" in the address bar). |
I guess I must have missed that. It seems to me that one should be able to set the "Source" property to null (or an empty string), since setting CoreWebView2Environment doesn't work after the "Source" property is set (as you stated). I tested the following workaround. If you go into the form designer (ex: Form1.Designer.cs), and comment out the line that sets the "Source" property (as seen below)
Then set the "Source" property after "EnsureCoreWebView2Async", it will work.
Here's the code from above with the modification. Also, as you can see, in the code below, I've changed it to use "C:\Temp" as the data directory.
When setting CoreWebView2Environment works, it creates a folder named "EBWebView" at the path that has been specified (ex: C:\Temp\EBWebView). Looks like this issue is mentioned in #177, as well as on StackOverflow-although in the StackOverflow post someone is using it with WPF. |
Thanks @cgeier that seems to work. |
Closing this issue - let me know if it should be re-opened. |
@pagoe-msft Setting "CoreWebView2Environment" when the WebView2 control was created with the Visual Studio Forms designer, doesn't appear to work. As described above, one needs to comment out (remove) the definition of the "Source" property because setting the "Source" property initializes the WebView2 control. Creating a new instance of WebView2 doesn't seem to have any effect. It seems, from my testing, that once the initialization has occurred, that initialization exists for all other WebView2 instances and can't be changed. This seems like undesirable behavior. |
@ndreisg It appears the code I posted above is flawed. InitializeWebView2Async should be "Task" not "void" and it should be called using "await". Without using "await" in the "Load" event handler, the code won't execute in the expected order. Instead of:
it should be:
Instead of:
It should be:
Here's a corrected example:
|
When I try to run my Windows Forms application with WebView2 from program files dir I get the following error:
The application is not elevated so I guess it doesn't have access in program files.
How do I change the
data directory
to another location?The text was updated successfully, but these errors were encountered: