Skip to content

Commit de58d21

Browse files
C#/WinRT docs: fix stale content, typos, and code errors
- index.md: Remove 'preview of authoring' (authoring is GA); remove '(Preview)' from Embedded support heading; fix 'Github' → 'GitHub'; update ms.date - authoring.md: fix 'Github' → 'GitHub'; update ms.date - agile-objects.md: add missing semicolon in code example; update ms.date - net-mappings-of-winrt-types.md: fix self-referential NOTE (now links to UWP mappings page); fix malformed Matrix3D table row (spurious opening parenthesis); update ms.date - create-windows-runtime-component-cswinrt.md: update VS prereq to '2022 or later'; remove pinned C#/WinRT version 1.4.1 (use latest); update ms.date - net-projection-from-cppwinrt-component.md: update two .NET 6.0 LTS references to .NET 8.0 LTS (.NET 6 support ended Nov 2024); update ms.date - create-winrt-component-winui-cswinrt.md: fix 'Github' → 'GitHub' (×3); add 'or later' to .NET 6.0 SDK prereq; update ms.date Co-authored-by: Copilot <[email protected]>
1 parent 422c7e9 commit de58d21

7 files changed

Lines changed: 22 additions & 32 deletions

hub/apps/develop/platform/csharp-winrt/agile-objects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: An agile object is one that can be accessed from any thread. C#/WinRT provides support for agile references if you need to marshal a non-agile object across apartments in a safe way.
33
title: Agile objects with C#/WinRT
4-
ms.date: 11/17/2020
4+
ms.date: 04/13/2026
55
ms.topic: article
66
ms.localizationpriority: medium
77
---
@@ -40,6 +40,6 @@ You can now pass `agileReference` to a thread in a different apartment, and use
4040

4141
```csharp
4242
await Task.Run(() => {
43-
Windows.UI.Popups.PopupMenu nonAgileObjAgain = agileReference.Get()
43+
Windows.UI.Popups.PopupMenu nonAgileObjAgain = agileReference.Get();
4444
});
4545
```

hub/apps/develop/platform/csharp-winrt/authoring.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Author Windows Runtime components with C#/WinRT
33
description: Overview of authoring Windows Runtime Components with C#/WinRT
4-
ms.date: 03/15/2022
4+
ms.date: 04/13/2026
55
ms.topic: article
66
ms.localizationpriority: medium
77
---
@@ -15,7 +15,7 @@ The C#/WinRT NuGet package provides support for authoring your own Windows Runti
1515

1616
For a walkthrough showing how to author a Windows Runtime component with .NET 6, and how to consume it from a C++/WinRT console application, see [Walkthrough: Create a C#/WinRT component and consume it from C++/WinRT](./create-windows-runtime-component-cswinrt.md).
1717

18-
For more details, and to search for or file any issues, refer to the [C#/WinRT Github repo](https://github.com/microsoft/CsWinRT) and [Authoring C#/WinRT Components](https://github.com/microsoft/CsWinRT/blob/master/docs/authoring.md).
18+
For more details, and to search for or file any issues, refer to the [C#/WinRT GitHub repo](https://github.com/microsoft/CsWinRT) and [Authoring C#/WinRT Components](https://github.com/microsoft/CsWinRT/blob/master/docs/authoring.md).
1919

2020
## Declaring types in Windows Runtime components
2121

hub/apps/develop/platform/csharp-winrt/create-windows-runtime-component-cswinrt.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
---
22
title: Walkthrough—Create a C#/WinRT component, and consume it from C++/WinRT
33
description: Author a Windows Runtime component with C#/WinRT, and consume it from a native application.
4-
ms.date: 03/15/2022
5-
ms.topic: article
6-
ms.localizationpriority: medium
7-
---
8-
9-
# Walkthrough&mdash;Create a C#/WinRT component, and consume it from C++/WinRT
4+
ms.date: 04/13/2026, and consume it from C++/WinRT
105

116
C#/WinRT enables developers using .NET to author their own Windows Runtime components in C# using a class library project. Authored components can be consumed in native desktop applications as a package reference or as a project reference with a few modifications.
127

@@ -18,7 +13,7 @@ For a walkthrough on authoring WinUI 3 controls with C#/WinRT specifically for u
1813

1914
This walkthrough requires the following tools and components:
2015

21-
- [Visual Studio 2022](/visualstudio/releases/2022/release-notes)
16+
- [Visual Studio 2022 or later](/visualstudio/releases/2022/release-notes)
2217
- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet) or later
2318
- [C++/WinRT VSIX](https://marketplace.visualstudio.com/items?itemName=CppWinRTTeam.cppwinrt101804264) for C++/WinRT project templates
2419

@@ -41,7 +36,7 @@ Begin by creating a new project in Visual Studio. Select the **Class Library** p
4136

4237
a. In Solution Explorer, right click on the project node and select **Manage NuGet Packages**.
4338

44-
b. Search for the **Microsoft.Windows.CsWinRT** NuGet package and install the latest version. This walkthrough uses C#/WinRT version 1.4.1.
39+
b. Search for the **Microsoft.Windows.CsWinRT** NuGet package and install the latest version.
4540

4641
3. Add a new `PropertyGroup` element that sets the `CsWinRTComponent` property. This specifies that your project is a Windows Runtime component so that a `.winmd` file is generated when you build the project.
4742

hub/apps/develop/platform/csharp-winrt/create-winrt-component-winui-cswinrt.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
---
22
title: Walkthrough—Create a C# component with WinUI controls, and consume it from a C++/WinRT app that uses the Windows App SDK
33
description: Author a Windows Runtime component with C#/WinRT with WinUI controls, and consume it from any Windows App SDK app.
4-
ms.date: 03/15/2022
5-
ms.topic: article
6-
ms.localizationpriority: medium
7-
---
8-
9-
# Walkthrough&mdash;Create a C# component with WinUI 3 controls, and consume it from a C++/WinRT app that uses the Windows App SDK
4+
ms.date: 04/13/2026, and consume it from a C++/WinRT app that uses the Windows App SDK
105

116
C#/WinRT provides support for authoring Windows Runtime components, including WinUI custom types and custom controls. These components can be consumed from either C# or C++/WinRT applications that use the Windows App SDK. We recommend using C#/WinRT v1.6.4 or later to author runtime components with NuGet packaging support.
127

@@ -19,7 +14,7 @@ This walkthrough demonstrates how to author a C# component with a custom WinUI c
1914
This walkthrough requires the following tools and components:
2015

2116
- [Visual Studio 2026](/visualstudio/releases/2026/release-notes)
22-
- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
17+
- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) or later
2318
- [Windows App SDK VSIX](../../../windows-app-sdk/downloads.md) (1.1 from the stable channel)
2419

2520
## Author your C#/WinRT component using the Windows App SDK
@@ -104,7 +99,7 @@ This walkthrough requires the following tools and components:
10499
1. You can now build the **WinUIComponentCs** project to generate a `.winmd` file for the component.
105100

106101
> [!NOTE]
107-
> You can also package the component as a NuGet package for end app consumers to reference. For more details, see [Authoring C#/WinRT components](https://github.com/microsoft/CsWinRT/blob/master/docs/authoring.md) on the C#/WinRT Github repo.
102+
> You can also package the component as a NuGet package for end app consumers to reference. For more details, see [Authoring C#/WinRT components](https://github.com/microsoft/CsWinRT/blob/master/docs/authoring.md) on the C#/WinRT GitHub repo.
108103

109104
## Reference the component from a Windows App SDK C++/WinRT app
110105

@@ -177,8 +172,8 @@ Consumption from packaged apps that use a separate **Windows Application Packagi
177172

178173
## Known issues
179174

180-
- Consuming a C# component as a project reference requires `PublishReadyToRun` to be set to `False`. See [Github Issue #1151](https://github.com/microsoft/CsWinRT/issues/1151) for more details.
181-
- Consuming a C# component built for `AnyCPU` from C++ is supported only from `x86` applications currently. `x64` and `Arm64` apps result in a runtime error similar to: *%1 is not a valid Win32 application.* See [Github Issue #1151](https://github.com/microsoft/CsWinRT/issues/1093) for more details.
175+
- Consuming a C# component as a project reference requires `PublishReadyToRun` to be set to `False`. See [GitHub Issue #1151](https://github.com/microsoft/CsWinRT/issues/1151) for more details.
176+
- Consuming a C# component built for `AnyCPU` from C++ is supported only from `x86` applications currently. `x64` and `Arm64` apps result in a runtime error similar to: *%1 is not a valid Win32 application.* See [GitHub Issue #1151](https://github.com/microsoft/CsWinRT/issues/1093) for more details.
182177

183178
## Related topics
184179

hub/apps/develop/platform/csharp-winrt/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: C#/WinRT is a tool set that provides WinRT projection support for C# code.
33
title: C#/WinRT
4-
ms.date: 05/19/2020
4+
ms.date: 04/13/2026
55
ms.topic: article
66
keywords: windows 10, uwp, standard, c#, winrt, cswinrt, projection
77
ms.localizationpriority: medium
@@ -13,7 +13,7 @@ C#/WinRT is a NuGet-packaged toolkit that provides Windows Runtime (WinRT) proje
1313

1414
C#/WinRT currently provides support for consuming WinRT APIs through the use of [Target Framework Monikers](../../../desktop/modernize/desktop-to-uwp-enhance.md) (TFMs) in .NET. Setting the TFM with a specific Windows SDK version adds references to the Windows SDK projection and runtime assemblies generated by C#/WinRT.
1515

16-
The [C#/WinRT NuGet package](https://www.nuget.org/packages/Microsoft.Windows.CsWinRT/) enables you to [create](#generate-and-distribute-an-interop-assembly) and [reference](#reference-an-interop-assembly) your own WinRT interop assemblies for .NET consumers. The latest C#/WinRT version also includes a [preview of authoring](create-windows-runtime-component-cswinrt.md) WinRT types in C#.
16+
The [C#/WinRT NuGet package](https://www.nuget.org/packages/Microsoft.Windows.CsWinRT/) enables you to [create](#generate-and-distribute-an-interop-assembly) and [reference](#reference-an-interop-assembly) your own WinRT interop assemblies for .NET consumers. The latest C#/WinRT version also supports [authoring](create-windows-runtime-component-cswinrt.md) WinRT types in C#.
1717

1818
For additional information, see the [C#/WinRT GitHub repo](https://aka.ms/cswinrt/repo).
1919

@@ -29,7 +29,7 @@ Finally, C#/WinRT is a general toolkit and is intended to support other scenario
2929

3030
## What's new
3131

32-
The latest C#/WinRT releases can be found on our [release notes](https://github.com/microsoft/CsWinRT/releases) page in the Github repo.
32+
The latest C#/WinRT releases can be found on our [release notes](https://github.com/microsoft/CsWinRT/releases) page in the GitHub repo.
3333

3434
## Usage
3535

@@ -47,7 +47,7 @@ Typically, C#/WinRT interop assemblies are referenced by application projects. B
4747

4848
If you distribute a third-party WinRT component without an official interop assembly, an application project may follow the procedure for [generating an interop assembly](#generate-and-distribute-an-interop-assembly) to generate its own private projection sources. We don't recommend this approach, because it can produce conflicting projections of the same type within a process. NuGet packaging, following the [Semantic Versioning](https://semver.org) scheme, is designed to prevent this. An official third-party interop assembly is preferred.
4949

50-
### Embedded support for WinRT types (Preview)
50+
### Embedded support for WinRT types
5151

5252
Starting with C#/WinRT version 1.4.1, support is included for embedding Windows SDK projection and runtime sources for both .NET and .NET Standard 2.0 into your library or app's output. This is useful in cases where usage of Windows SDK types is self-contained. Embedded support removes dependencies on WinRT.Runtime.dll and Microsoft.Windows.SDK.NET.dll which reduces the library or app output size. It also allows library developers to provide downlevel support and removes the need for multi-targeting.
5353

hub/apps/develop/platform/csharp-winrt/net-mappings-of-winrt-types.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: .NET mappings of WinRT types in C#/WinRT
33
description: The following table lists the mappings that C#/WinRT makes between Windows Runtime types and .NET types.
4-
ms.date: 04/19/2020
4+
ms.date: 04/13/2026
55
ms.topic: article
66
keywords: windows 10, uwp
77
ms.localizationpriority: medium
@@ -18,7 +18,7 @@ The C#/WinRT custom type mappings are categorized by types in the Windows SDK or
1818
- **WinRT types that map to .NET types with the same name and namespace.** These custom mappings are generally for performance or enhancement reasons, and are implemented directly in C#. Most of the types that have the same namespace name and type name in WinRT and .NET are structures (or types associated with structures, such as enumerations). In WinRT, structures have no members other than fields, and require helper types, which .NET hides. The .NET versions of these structures have properties and methods that provide the functionality of the hidden helper types (for example, **Windows.UI.Color**).
1919

2020
> [!NOTE]
21-
> For a list of mappings between WinRT and .NET types in the context of UWP apps, see [.NET mappings of WinRT types in UWP](/windows/apps/develop/platform/csharp-winrt/net-mappings-of-winrt-types).
21+
> For a list of mappings between WinRT and .NET types in the context of UWP apps, see [.NET mappings of Windows Runtime types](/windows/uwp/winrt-components/net-framework-mappings-of-windows-runtime-types).
2222
2323
## Mappings for WinRT types in the Windows SDK
2424

@@ -99,4 +99,4 @@ The C#/WinRT custom type mappings are categorized by types in the Windows SDK or
9999
| KeyTime | Microsoft.UI.Xaml.Media.Animation |
100100
| RepeatBehavior | Microsoft.UI.Xaml.Media.Animation |
101101
| RepeatBehaviorType | Microsoft.UI.Xaml.Media.Animation |
102-
| Matrix3D |(Microsoft.UI.Xaml.Media.Media3D |
102+
| Matrix3D | Microsoft.UI.Xaml.Media.Media3D |

hub/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Generate a C# projection from a C++/WinRT component, distribute as a NuGet for .NET apps
33
description: In this topic, we walk through using [C#/WinRT](/windows/uwp/csharp-winrt/) to generate a C# .NET projection (or interop) assembly from a C++/WinRT Windows Runtime component, and distribute it as a NuGet package for .NET applications.
4-
ms.date: 03/23/2023
4+
ms.date: 04/13/2026
55
ms.topic: how-to
66
keywords: windows 10, c#, winrt, cswinrt, projection
77
ms.localizationpriority: medium
@@ -73,7 +73,7 @@ First, with the **CppWinRTComponentProjectionSample** solution still open in Vis
7373
1. In **Solution Explorer**, right-click your solution node and click **Add** > **New Project**.
7474
2. In the **Add a new project** dialog box, type **Class Library** in the search box. Choose **C#** from the language list, and then choose **Windows** from the platform list. Choose the C# project template that's called simply **Class Library** (with no prefixes nor suffixes), and click **Next**.
7575
3. Name the new project *SimpleMathProjection*. The location should already be set to the same `\CsWinRT\src\Samples\NetProjectionSample` folder that the **SimpleMathComponent** folder is in; but confirm that. Then click **Next**.
76-
4. On the **Additional information** page, select **.NET 6.0 (Long-term support)**, and then choose **Create**.
76+
4. On the **Additional information** page, select **.NET 8.0 (Long-term support)**, and then choose **Create**.
7777

7878
2. Delete the stub **Class1.cs** file from the project.
7979

@@ -235,7 +235,7 @@ To consume **SimpleMathComponent** from a .NET project, you can simply add to a
235235
1. In a new instance of Visual Studio, select **File** > **New** > **Project**.
236236
2. In the **Create a new project** dialog box, search for the **Console App** project template. Choose the C# project template that's called simply **Console App** (with no prefixes nor suffixes), and click **Next**. If you're using Visual Studio 2019, then the project template is **Console Application**.
237237
3. Name the new project **SampleConsoleApp**, set its location to the same `\CsWinRT\src\Samples\NetProjectionSample` folder that the **SimpleMathComponent** and **SimpleMathProjection** folders are in, and click **Next**.
238-
4. On the **Additional information** page, select **.NET 6.0 (Long-term support)**, and then choose **Create**.
238+
4. On the **Additional information** page, select **.NET 8.0 (Long-term support)**, and then choose **Create**.
239239

240240
2. In **Solution Explorer**, double-click the **SampleConsoleApp** node to open the **SampleConsoleApp.csproj** project file, and edit the `TargetFramework` and `Platform` properties so that they look as shown in the following listing. Add the `Platform` element if it's not there.
241241

0 commit comments

Comments
 (0)