Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add information about pitfalls and usage of derived COM interfaces across assembly boundaries #42051

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/standard/native-interop/comwrappers-source-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,20 @@ interface IDerived : IBase

Note that an interface with the `GeneratedComInterface` attribute can only inherit from one base interface that has the `GeneratedComInterface` attribute.

#### Derived interfaces across assembly boundaries

In .NET 8, defining an interface with the `GeneratedComInterface` attribute that derives from a `GeneratedComInterface`-attributed interface defined in another assembly is not supported.
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved

In .NET 9 and newer, this scenario is supported only for specific scenarios:
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved

- The base interface type must be compiled targeting the same target framework as the derived type.
- The base interface type must not shadow any members of its base interface, if it has one.

Additionally, any changes to any generated virtual method offsets in the base interface chain defined in another assembly will not be accounted for in the derived interfaces until the project is rebuilt.
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved

> [!NOTE]
> In .NET 9 and newer, a warning is emitted when inheriting generated COM interfaces across assembly boundaries to inform you about the restrictions and pitfalls of using this feature. This warning can be disabled to acknowlege the limitations and inherit across assembly boundaries.
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved

### Marshal APIs

Some APIs in <xref:System.Runtime.InteropServices.Marshal> are not compatible with source-generated COM. Replace these methods with their corresponding methods on a `ComWrappers` implementation.
Expand Down
Loading