Description
- .NET Core Version: .NET 5.0.101
- Have you experienced this same bug with .NET Framework?: No.
Problem description:
As of .NET 5.0, the “window.external” object reference that’s intended to provide access to the WebBrowser.ObjectForScripting property value does not work. It worked in .NET Core 3.1.
I didn't find any information about this behavior in the .NET 5 documentation for Breaking Changes or Known Issues.
Evaluating “window.external” in the control’s browser environment produces the following error message:
“Unexpected call to method or property access.”
Here’s a screenshot of the error:
Expected behavior:
A "normal" message box should show (with the message "called from script code").
Minimal repro:
https://github.com/rummelsworth/WebBrowserControlTutorial
The above-linked repo is an implementation of the WebBrowser control's "2-way communication" tutorial. It has 3 branches:
- One branch targets netcoreapp3.1 and does not reproduce the error.
- The main branch targets net5.0 and reproduces the error.
- Another branch also targets net5.0 but has been migrated to use WebView2 instead of WebBrowser.