Skip to content

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

Open
@rummelsworth

Description

@rummelsworth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri2Medium prioritydoc-bugProblem with the content; needs to be fixed [org][type][category]dotnet-framework/svcokr-healthContent-health KR: Concerns article defects/freshness or build warnings.okr-qualitywinforms/subsvc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions