Repository navigation
Description
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
Issue metadata
- Issue type: breaking-change
Activity
[-]Built-in support for WinRT is remove from .NET 5.0[/-][+]Built-in support for WinRT is removed from .NET 5.0[/+]danmoseley commentedon Jun 9, 2020
Would it be helpful to include the typical error(s) that code could produce that is encountering this break? Eg., what was in the two issues you looked at this morning. That might make it much easier to find this page once you've hit the problem.
Also, do we have sufficient help for someone making the jump to the new toolchain?
AaronRobinsonMSFT commentedon Jun 9, 2020
@gewarren This change was made in preview 6, not preview 5. I mean .NET 5.0 Preview 6. I submit that your team may have different preview numbers.
AaronRobinsonMSFT commentedon Jun 9, 2020
Yep. We have had someone ask a question already: dotnet/runtime#35318 (comment).
gewarren commentedon Jun 9, 2020
Ok thanks. I'll delete my original comment just so there's no confusion. (We don't use different preview numbers.)
fixes dotnet#18875
Add WinRT removal breaking change (#19086)