Describe the bug
When consuming either of the Holographic App Remoting packages (i.e. Windows/OpenXR) from a managed project, the native binaries are not copied to the output directory properly. Note that the Windows package can be used from C# with CSWinRT, and the OpenXR package can be used from C# with Silk.NET (with some manual bindings for the Remoting extensions...). For dotnet to deploy the native binaries auto-magically, the package should provide the following layout (similarly for other architectures/runtime-identifiers as needed):
runtimes/win-x64/native/... <-- desktop binaries go here
runtimes/win10-x64/nativeassets/uap10.0/... <-- UWP binaries go here
using var context = Microsoft.Holographic.AppRemoting.RemoteContext.Create();
Make the following required changes to the .csproj:
Change TargetFramework to net7.0-windows10.0.19041.0
Add property CsWinRTIncludes with value Microsoft.Holographic.AppRemoting
Make the following accomodations to the .csproj to enable the current Remoting nuget package (arguably, the nuget package should handle this automatically too...):
Add GeneratePathProperty="true" to the PackageReference for the Remoting package (only needed to support the next step)
Add the following snippet to reference the .winmd:
Expected: Program runs and prints "Hello, world!"
Actual: "Class not registered" exception thrown since CsWinRT can't find the native dll.
Workaround
To work around this, the following snippet can be used, but it's limited to hard-coding a single architecture (dotnet knows how to dynamically select the proper native binaries for the current architecture from the nuget package at runtime):
Describe the bug When consuming either of the Holographic App Remoting packages (i.e. Windows/OpenXR) from a managed project, the native binaries are not copied to the output directory properly. Note that the Windows package can be used from C# with CSWinRT, and the OpenXR package can be used from C# with Silk.NET (with some manual bindings for the Remoting extensions...). For
dotnet
to deploy the native binaries auto-magically, the package should provide the following layout (similarly for other architectures/runtime-identifiers as needed):runtimes/win-x64/native/...
<-- desktop binaries go hereruntimes/win10-x64/nativeassets/uap10.0/...
<-- UWP binaries go hereNote, Remoting + StereoKit is a tasty combo, and can be easily used by simply referencing https://www.nuget.org/packages/StereoKit.HolographicRemoting!
To Reproduce
dotnet new console
dotnet add package Microsoft.Holographic.AppRemoting
dotnet add package Microsoft.Windows.CsWinRT
Program.cs
:TargetFramework
tonet7.0-windows10.0.19041.0
CsWinRTIncludes
with valueMicrosoft.Holographic.AppRemoting
GeneratePathProperty="true"
to thePackageReference
for the Remoting package (only needed to support the next step)dotnet run
Expected: Program runs and prints "Hello, world!" Actual: "Class not registered" exception thrown since CsWinRT can't find the native dll.
Workaround To work around this, the following snippet can be used, but it's limited to hard-coding a single architecture (
dotnet
knows how to dynamically select the proper native binaries for the current architecture from the nuget package at runtime):