Skip to content

Commit 2f69c0a

Browse files
Edit known issues for WinRT com interop (#1754)
* add solution to issue * Edits * Updated formatting. * Formatted text * Formatted text Co-authored-by: McLean Schofield <[email protected]>
1 parent e95de79 commit 2f69c0a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

hub/apps/desktop/modernize/winrt-com-interop-csharp.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ As a replacement, starting with the .NET 5.0.205 SDK and .NET 5.0.302 SDK releas
1818

1919
## Available interop classes
2020

21-
The following is a list of available C# interop classes and the mappings to the underlying COM interfaces. All classes listed below implement the methods of the associated COM interface and provide type-safe wrappers for parameters and return values. For example, `DragDropManagerInterop.GetForWindow` requires an `IntPtr` window handle parameter and returns a [CoreDragDropManager](/uwp/api/windows.applicationmodel.datatransfer.dragdrop.core.coredragdropmanager) object. All of the WinRT COM interop classes below and associated methods are static.
21+
The following is a list of available C# interop classes and the mappings to the underlying COM interfaces. All classes listed below implement the methods of the associated COM interface and provide type-safe wrappers for parameters and return values. For example, **DragDropManagerInterop.GetForWindow** requires an **IntPtr** window handle parameter and returns a [CoreDragDropManager](/uwp/api/windows.applicationmodel.datatransfer.dragdrop.core.coredragdropmanager) object. All of the WinRT COM interop classes below and associated methods are static.
2222

2323
| Class | COM interface |
2424
| -------------------------|-------|
2525
| WinRT.Interop.WindowNative | [IWindowNative](/windows/windows-app-sdk/api/win32/microsoft.ui.xaml.window/nn-microsoft-ui-xaml-window-iwindownative) |
2626
| WinRT.Interop.InitializeWithWindow | [IInitializeWithWindow](/windows/win32/api/shobjidl_core/nn-shobjidl_core-iinitializewithwindow) |
27-
| [Windows.ApplicationModel.DataTransfer.DragDrop.Core.DragDropManagerInterop | [IDragDropManagerInterop](/windows/win32/api/dragdropinterop/nn-dragdropinterop-idragdropmanagerinterop) |
27+
| Windows.ApplicationModel.DataTransfer.DragDrop.Core.DragDropManagerInterop | [IDragDropManagerInterop](/windows/win32/api/dragdropinterop/nn-dragdropinterop-idragdropmanagerinterop) |
2828
| Windows.Graphics.Printing.PrintManagerInterop | [IPrintManagerInterop](/windows/win32/api/printmanagerinterop/nn-printmanagerinterop-iprintmanagerinterop) |
2929
| Windows.Media.SystemMediaTransportControlsInterop | [ISystemMediaTransportControlsInterop](/windows/win32/api/systemmediatransportcontrolsinterop/nn-systemmediatransportcontrolsinterop-isystemmediatransportcontrolsinterop) |
3030
| Windows.Media.PlayTo.PlayToManagerInterop | [IPlayToManagerInterop](/windows/win32/api/playtomanagerinterop/nn-playtomanagerinterop-iplaytomanagerinterop) |
@@ -40,19 +40,19 @@ The following is a list of available C# interop classes and the mappings to the
4040

4141
## Configure a .NET 5+ desktop project to use the C# interop classes
4242

43-
To configure your desktop project to access the C# interop classes, you can follow these steps:
43+
To configure your desktop project to access the C# interop classes, follow these steps:
4444

45-
1. Open the project file for your C# project. In the *csproj* file, modify the `TargetFramework` element to target a specific Windows SDK version. For example, the following element is for a project that targets Windows 10, version 2004.
45+
1. Open the project file for your C# project. In the .csproj file, modify the `TargetFramework` element to target a specific Windows SDK version. For example, the following element is for a project that targets Windows 10, version 2004.
4646

4747
```xml
4848
<PropertyGroup>
4949
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
5050
</PropertyGroup>
5151
```
5252

53-
For more information including a list of other supported values, see [this article](desktop-to-uwp-enhance.md#net-5-use-the-target-framework-moniker-option).
53+
For more information including a list of other supported values, see [Use the Target Framework Moniker option](desktop-to-uwp-enhance.md#net-5-use-the-target-framework-moniker-option).
5454

55-
2. The following example demonstrates how to use the `WinRT.Interop.WindowNative` interop class in a [WinUI 3-based application](../../winui/winui3/create-your-first-winui3-app.md) to obtain a window handle object and then open a folder picker dialog using the window handle. In this example, the `this` object is an instance of the [Microsoft.UI.Xaml.Window](/windows/winui/api/microsoft.ui.xaml.window) class provided by WinUI 3. Note that the `WinRT.Interop.WindowNative` class implements the [IWindowNative](/windows/windows-app-sdk/api/win32/microsoft.ui.xaml.window/nn-microsoft-ui-xaml-window-iwindownative) interface provided by WinUI 3, and this interface is implemented by the [Microsoft.UI.Xaml.Window](/windows/winui/api/microsoft.ui.xaml.window) class.
55+
2. The following example demonstrates how to use the **WinRT.Interop.WindowNative** interop class in a [WinUI 3-based application](../../winui/winui3/create-your-first-winui3-app.md) to obtain a window handle object and then open a folder picker dialog using the window handle. In this example, the `this` object is an instance of the [Microsoft.UI.Xaml.Window](/windows/winui/api/microsoft.ui.xaml.window) class provided by WinUI 3. Note that the **WinRT.Interop.WindowNative** class implements the [IWindowNative](/windows/windows-app-sdk/api/win32/microsoft.ui.xaml.window/nn-microsoft-ui-xaml-window-iwindownative) interface provided by WinUI 3, and this interface is implemented by the [Microsoft.UI.Xaml.Window](/windows/winui/api/microsoft.ui.xaml.window) class.
5656

5757
```csharp
5858
private async void myButton_Click(object sender, RoutedEventArgs e)
@@ -68,10 +68,10 @@ To configure your desktop project to access the C# interop classes, you can foll
6868
}
6969
```
7070

71-
## Known issues
71+
## Troubleshooting and known issues
7272

73-
The APIs listed in this article are new and developers may encounter issues. The following are known issues with the COM interop APIs provided by the .NET 5 Windows-specific Target Framework Monikers (TFMs).
73+
This section lists known issues and solutions for using the WinRT COM interop APIs. To provide feedback or to report other issues, add your feedback to an existing issue or file a new issue on the [C#/WinRT GitHub repo](https://github.com/microsoft/CsWinRT).
74+
75+
- **WinRT.Interop.WindowNative.GetWindowHandle does not marshal window handles (HWNDs) correctly when running on x86 platforms.** To resolve this issue, update your .NET 5 SDK version to one of the following versions (or later): .NET SDK 5.0.206, 5.0.303, or 5.0.400.
7476

75-
- WinRT.Interop.WindowNative.GetWindowHandle does not marshal HWND correctly when running on x86
7677

77-
To provide feedback or to report other issues, please contribute to an existing issue or file a new issue on the [C#/WinRT GitHub repo](https://github.com/microsoft/CsWinRT).

0 commit comments

Comments
 (0)