docs-desktop icon indicating copy to clipboard operation
docs-desktop copied to clipboard

WebBrowser interop API how-to example code does not work in .NET 5.0

Open rummelsworth opened this issue 4 years ago • 1 comments

This how-to contains example code that worked in .NET Core 3.1 but no longer works in .NET 5.0.

See dotnet/winforms#4443 for details.

I recognize this how-to page is only for .NET Framework 4.8, but there is no other version of this how-to, and WebBrowser is a supported API of both .NET Core 3.1 and .NET 5.0.

Please consider either (a) adding a "note" element in this how-to with a warning and explanation of the issue for .NET 5.0 or (b) create and appropriately update a copy of this how-to for .NET 5.0.

If it's useful to summarize here, the correct code for .NET 5.0 should either:

  • (a) define an interface containing the signature of Test, add that interface to Form1's declaration, then annotate Form1 with ComDefaultInterface; or

  • (b) extract Test to a new type, then assign an instance of that type to ObjectForScripting (instead of assigning this).


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

rummelsworth avatar Jan 14 '21 17:01 rummelsworth

Thank you for filing this bug. We have plans to eventually detail the new WebView2 control and probably not talk about the old control much. If you feel up to it, please open a PR with your suggested edits. This will get the details published faster instead of having myself research it. Please tag RussKie for review. Thanks!

adegeo avatar Jan 15 '21 21:01 adegeo