Authoring Windows Runtime components with C#/WinRT is supported on .NET 6 and later.
The C#/WinRT NuGet package provides support for authoring your own Windows Runtime types and components in C#, and consuming them from any Windows Runtime-compatible language such as C++/WinRT or Rust. C#/WinRT authoring and hosting support requires .NET 6 and Visual Studio 2022, and it is intended to support desktop application scenarios including the Windows App SDK, and WinUI3.
While authoring your Windows Runtime component, follow the guidelines and type restrictions outlined in the existing UWP documentation about Windows Runtime components (see Windows Runtime components with C# and Visual Basic). The component can for the most part be implemented like any other C# library. However, there are restrictions on the public types in the component that will be exposed to the Windows Runtime and declared in the generated .winmd for others to consume.
Externally, you can expose only Windows Runtime types for parameters and return values. You can use built-in C# types as part of the public surface of the component as long as there is a mapping from the .NET type to WinRT (see .NET mappings of WinRT types in C#/WinRT), and they will appear to users of the component as the corresponding Windows Runtime types. Windows Runtime types from other Windows Runtime components and the Windows SDK can also be used as part of the public implementation of the component, such as in parameters, return types, and class inheritance.
Not
There are some Windows Runtime types that are mapped to .NET types (see .NET mappings of WinRT types in C#/WinRT). These .NET types can be used in the public interface of your Windows Runtime component, and they will appear to users of the component as the corresponding Windows Runtime types.
Bu içeriğin kaynağı GitHub'da bulunabilir; burada ayrıca sorunları ve çekme isteklerini oluşturup gözden geçirebilirsiniz. Daha fazla bilgi için katkıda bulunan kılavuzumuzu inceleyin.
Windows developer geri bildirimi
Windows developer, açık kaynak bir projedir. Geri bildirim sağlamak için bir bağlantı seçin: