"window.external" evaluation in WebBrowser control gives error "Unexpected call to method or property access."
See original GitHub issue- .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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
@RussKie I think the links are visible above my previous comment in the GitHub UI but probably not included in the notification emails. Here are the links:
Thanks again.
I bisected it, and it looks like we regressed in #3388.
@weltkante looks like not all
ComVisible
attributes were incorrect after all.