MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: Webview2 fails to initialize hosted inside Visual Studio (VSIX) when using implicit init via the `Source` property with `CreationProperties` set
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
When you try to initialize Webview2 by using the Source property from WPF hosted in a Visual Studio extension and have CreationProperties set, you will get a weird ArgumentException on WPF/XAML trying to set CreationProperties and the webview will fail to initialize. Doing the exact same thing but using EnsureCoreWebView2Async and Navigate instead of the Source property does work.
System.Windows.Markup.XamlParseException
HResult=0x80131501
Message='Set property 'Microsoft.Web.WebView2.Wpf.WebView2Base.CreationProperties' threw an exception.' Line number '19' and line position '10'.
Source=PresentationFramework
StackTrace:
at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
This exception was originally thrown at this call stack:
System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty, object, System.Windows.PropertyMetadata, bool, bool, System.Windows.OperationType, bool)
System.Windows.Baml2006.WpfMemberInvoker.SetValue(object, object)
MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(object, System.Xaml.XamlMember, object)
Inner Exception 1:
ArgumentException: 'Microsoft.Web.WebView2.Wpf.CoreWebView2CreationProperties' is not a valid value for property 'CreationProperties'.
Importance
Low. My app is not very affected, or this only affects development.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
133.0.3065.69
SDK Version
1.0.3065.39
Framework
WPF
Operating System
Windows 11
OS Version
10.0.26100.0
Repro steps
- Clone https://github.com/segevfiner/Webview2FocusIssueVSIX
- Open the solution in Visual Studio.
- Run it (F5).
- Press View -> Webview2 Not Working.
- You will get an error.
- Close the experimental Visual Studio instance, and open it again (F5)
- Press View -> Webview2 Working.
- It will work.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Clone Webview2FocusIssueVSIX and follow the listed F5 repro steps. Compare the failing WPF path using Source with CreationProperties against the working EnsureCoreWebView2Async and Navigate path. Done means identifying why implicit initialization fails in the Visual Studio extension and documenting or fixing that behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100