Skip to content
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/Bug]: Webview2 fails to initialize hosted inside Visual Studio (VSIX) when using implicit init via the Source property with CreationProperties set #5119

Open
segevfiner opened this issue Feb 20, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@segevfiner
Copy link

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

@segevfiner segevfiner added the bug Something isn't working label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant