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

Open
#169 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
38/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Update dotnet-desktop-guide/framework/winforms/controls/implement-two-way-com-between-dhtml-and-client.md. First read the linked dotnet/winforms#4443 issue and compare its .NET 5.0 guidance with the existing .NET Framework 4.8 example. Done means the page warns about the incompatibility or provides an appropriately updated .NET 5.0 version.

Written by the indexing model from the issue text.

Description

doc-bug dotnet-framework/svc okr-health okr-quality Pri2 winforms/subsvc

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.

Dominant language
C#
Stars
241
Forks
192
Avg merge
10h 23m
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/docs-desktop

All issues in dotnet/docs-desktop

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.