Description
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 toForm1
's declaration, then annotateForm1
withComDefaultInterface
; or -
(b) extract
Test
to a new type, then assign an instance of that type toObjectForScripting
(instead of assigningthis
).
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: c586d0c9-fb61-4fb5-6f7b-2d1a8abc0dd4
- Version Independent ID: 5e8ef638-ba4d-4b78-b9b4-79e4732b77c8
- Content: How to: Implement Two-Way Communication Between DHTML Code and Client Application Code - Windows Forms .NET Framework
- Content Source: dotnet-desktop-guide/framework/winforms/controls/implement-two-way-com-between-dhtml-and-client.md
- Product: dotnet-framework
- Technology: dotnet-winforms
- GitHub Login: @adegeo
- Microsoft Alias: adegeo