InteropCompositor 1.0.0

Install-Package InteropCompositor -Version 1.0.0
dotnet add package InteropCompositor --version 1.0.0
<PackageReference Include="InteropCompositor" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add InteropCompositor --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: InteropCompositor, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install InteropCompositor as a Cake Addin
#addin nuget:?package=InteropCompositor&version=1.0.0

// Install InteropCompositor as a Cake Tool
#tool nuget:?package=InteropCompositor&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Interop Compositor

With the release of .NET5 Preview 8, Microsoft introduced a streamlined way for .NET developers to access the set of Windows Runtime (WinRT) APIs that are shipped as part of Windows..NET5 applications can now access Windows APIs through a new set of Target Framework Monikers (TFMs), which have been extended to support platform specific APIs.

This change means that applications targeting .NET5 no longer need to reference the Microsoft.Windows.SDK.Contracts NuGet package. But in Target Framework Moniker Using Compositor object to get ICompositorDesktopInterop throws exception

System.PlatformNotSupportedException: 'Marshalling as IInspectable is not supported in the .NET runtime.'

To overcome this issue you can use InteropCompositor.


NuGet Package

Install-Package InteropCompositor


Set the TargetFramework in the project file


and in your code use

Compositor compositor = new Compositor();
ICompositorDesktopInterop interop = compositor.TryAs<ICompositorDesktopInterop>();
interop.CreateDesktopWindowTarget(hwnd, true, out var target).ThrowOnError();
ICompositionTarget compositionTarget = (ICompositionTarget)target;

Note: Don't forget to create DispatcherQueueController on MainWindow Constructor.

Credits 🏅

Simon Mourier and his Repository DirectN

  • net5.0-windows10.0.19041

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 98 8/26/2021