News

C#/WinRT Authoring Preview Unveiled

Microsoft unveiled a preview of authoring support in an update to the C#/WinRT tool used to help C# developers more easily work with interfaces to the Windows Runtime, the underlying infrastructure used by Windows to expose its APIs.

The C#/WinRT GitHub site says it "provides Windows Runtime (WinRT) projection support for the C# language. A 'projection' is an adapter that enables programming the WinRT APIs in a natural and familiar way for the target language. The C#/WinRT projection hides the details of interop between C# and WinRT interfaces, and provides mappings of many WinRT types to appropriate .NET equivalents, such as strings, URIs, common value types, and generic collections."

WinRT, first introduced in 2012 with Windows 8 and Windows Server 2012, succeeds the older, flat, C-based Win32 API.

Microsoft removed built-in support for C#/WinRT last summer in a .NET 5 preview, transferring it to NuGet where it has been downloaded more than 33,000 times. Documentation describing C#/WinRT says:

Previous versions of .NET Framework and .NET Core had built-in knowledge of WinRT, a Windows-specific technology. To support the portability and efficiency goals of .NET 5, we lifted the WinRT projection support out of the .NET compiler and runtime and moved it into the C#/WinRT toolkit. The goal of C#/WinRT is to provide parity with the built-in WinRT support provided by earlier versions of the C# compiler and .NET runtime.
A C++/WinRT tool has been around for several years now, downloaded more than 715,000 times from NuGet and more than 73,000 times as an extension in the Visual Studio Marketplace (there is no equivalent C#/WinRT extension).

Referencing an Interop Assembly
[Click on image for larger view.] Referencing an Interop Assembly (source: Microsoft).

The C#/WinRT tool -- currently in prerelease version 1.1.2 on NuGet -- is compatible with .NET 5 and does not require built-in knowledge of WinRT by the C# compiler, its description says.

In announcing an update to the tool, which hit v1.0 general availability in November along with .NET 5, Microsoft announced the preview support for authoring. "This allows component authors to create and package their own C# .NET 5 Windows Runtime components that can be consumed in native applications," Microsoft said.

The Feb. 9 post goes on to describe how to author a WinRT component, build and package it, consume it from a native application and more, including updates for the .NET 5.0 SDK February update with C#/WinRT version 1.1.1. The post also describes bug fixes and a new feature: support for SupportedOSPlatform attributes. "With the integration of these attribute checks in Visual Studio, you now get a CA1416 warning when calling platform-specific APIs that are not supported on the platform versions your project supports."

Going forward, the dev team is planning to add support for more authoring scenarios, including integration with WinUI 3 desktop applications, along with authoring out-of-process components for use in packaged applications.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Kubernetes for Developers

    Microsoft's Dan Wahlin previews his introductory "Kubernetes for Developers" session at Visual Studio Live! San Diego 2026, explaining how developers can get past the Kubernetes learning curve by starting locally, mastering Pods first, and using Services to make containerized applications reliably accessible.

  • VS Code Keeps Eye on Costs in v1.126 Update

    Visual Studio Code 1.126 adds session-level Copilot cost information, continuing Microsoft's recent focus on helping developers monitor and manage usage-based GitHub Copilot billing.

  • Open VSX 1.0.0 Puts Focus on Open Extension Registry for VS Code Ecosystem

    Eclipse Open VSX has reached 1.0.0, highlighting its role as a vendor-neutral registry for VS Code-compatible extensions.

  • Infragistics Puts MCP Toolchain at Center of Ultimate 26.1

    Infragistics Ultimate 26.1 introduces the Ignite UI Enterprise MCP toolchain for AI-assisted app development across Angular, React, Web Components and Blazor.

Subscribe on YouTube