Skip to content

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

Closed

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

Activity

  1. added
    breaking-change
    on Jun 9, 2020
  2. changed the title [-]Built-in support for WinRT is remove from .NET 5.0[/-] [+]Built-in support for WinRT is removed from .NET 5.0[/+] on Jun 9, 2020
  3. self-assigned this
    on Jun 9, 2020
  4. added and removed
    ⌚ Not Triaged
    on Jun 9, 2020
  5. danmoseley commented on Jun 9, 2020

    @danmoseley
    Contributor

    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?

  6. AaronRobinsonMSFT commented on Jun 9, 2020

    @AaronRobinsonMSFT
    MemberAuthor

    @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.

  7. AaronRobinsonMSFT commented on Jun 9, 2020

    @AaronRobinsonMSFT
    MemberAuthor

    Also, do we have sufficient help for someone making the jump to the new toolchain?

    Yep. We have had someone ask a question already: dotnet/runtime#35318 (comment).

  8. gewarren commented on Jun 9, 2020

    @gewarren
    Collaborator

    @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.

    Ok thanks. I'll delete my original comment just so there's no confusion. (We don't use different preview numbers.)

  9. added
    🏁 Release: .NET 5
    on Jun 19, 2020
  10. added a commit that references this issue on Jun 23, 2020
    026920c
  11. added a commit that references this issue on Jun 24, 2020
    c314b42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 5breaking-change

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions