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

Open
#5,119 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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
  1. Clone https://github.com/segevfiner/Webview2FocusIssueVSIX
  2. Open the solution in Visual Studio.
  3. Run it (F5).
  4. Press View -> Webview2 Not Working.
  5. You will get an error.
  6. Close the experimental Visual Studio instance, and open it again (F5)
  7. Press View -> Webview2 Working.
  8. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.