Skip to content

Built-in support for WinRT is removed from .NET 5.0 #18875

Closed
@AaronRobinsonMSFT

Description

@AaronRobinsonMSFT

Built-in support for WinRT is removed from .NET 5.0

Built-in support for consumption of WinRT APIs in .NET Core is being removed. This possibility has been announced in dotnet/runtime#35318.

The removal was done in dotnet/runtime#36715.

Version introduced

.NET 5.0

Old behavior

Consumption of WinMDs by CoreCLR was possible. This permitted activation and consumption of WinRT types.

New behavior

Direct consumption of WinMDs is no longer possible by CoreCLR.

Examples of failures that may now occur:

Attempting to reference a no longer supported WinRT related assembly:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime.InteropServices.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Activation of a WinRT class will result in the following:

Unhandled exception. System.PlatformNotSupportedException: Operation is not supported on this platform. (0x80131539)

Reason for change

  • WinRT can be developed and improved separate from the .NET runtime.
  • Symmetrical with interop systems provided for other OSes, like iOS and Android.
  • Can take advantage of many other .NET features (AOT, C# features, IL linking).
  • Simplifies the .NET runtime codebase.

Recommended action

Remove references to the Microsoft.Windows.SDK.Contracts package and replace them with references to the Microsoft.Windows.SDK.NET package.

Additionally, the recommendation is to use the C#/WinRT tool chain to generate or customize WinRT APIs and types in .NET 5.0 and beyond.

Category

Interop

Affected APIs

System.Runtime.InteropServices.WindowsRuntime

System.Runtime.WindowsRuntime


Issue metadata

  • Issue type: breaking-change

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 5Work items for the .NET 5 releasebreaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions