0

After releasing a UWP application to the Windows Store that runs well on both desktop and Xbox, I noticed that it was not launching successfully when installed as a 2D application on a HoloLens.

Hooking it up to a debugger I discovered the following error:

System.InvalidCastException: 'Unable to cast object of type 'Windows.UI.Composition.Compositor' to type 'Windows.UI.Composition.ICompositorWithRadialGradient'.'

on the following line of code:

CompositionRadialGradientBrush RGBrush = compositor.CreateRadialGradientBrush();

Is there a known compatibility issue with the HoloLens not supporting the radial gradient brush functionality of Windows.UI.Composition?

Besides conditionally skipping this section of code that applies the gradient background when running on a HoloLens are there any other ways to get around this or to get the api to work correctly?

HoloSheep
  • 53
  • 12
  • After testing, this API works as expected on the HoloLens2. Could you check for updates in Settings to see If there is a system update available for HoloLens 2 and try again? If the issue throws, please provide the detail steps and MVCE(stackoverflow.com/help/minimal-reproducible-example) for reproducing. Generally wondering the detailed steps to reproduce your issue. – Hernando - MSFT Apr 04 '22 at 09:56
  • Hi Hernando, This was on an original HoloLens. – HoloSheep Apr 05 '22 at 14:16
  • Double check there aren't any pending OS updates. – Lance McCarthy Apr 05 '22 at 21:36
  • Apparently 1809 is the last update for HoloLens 1 https://learn.microsoft.com/en-us/hololens/hololens1-release-notes – HoloSheep Apr 06 '22 at 04:32
  • HoloLens 1 has no further servicing for that platform. You could migrate though to HL2 device which can support the scenario. – Hernando - MSFT Apr 08 '22 at 10:01
  • @Hernando-MSFT the question is related to an app that is available in the Windows Store which is why I was looking for clarity and confirmation if this is a compatibility issue. Were you able to try your test on a HoloLens 1 device? – HoloSheep Apr 08 '22 at 14:19
  • And if it is specific to the HoloLens 1, is there a reliable way to programmatically check when the app is specifically running on a HoloLens 1 and not on HoloLens 2 or Mixed Reality? – HoloSheep Apr 08 '22 at 17:37

1 Answers1

0

HoloSheep,

To detect if running on HL1 or HL2, there is stack overflow post that details how to do that via application code. This is from post:

"the best way to do this is by using platform capabilities utility, since that will work as new devices come out, and across platforms. For example, instead of checking "am on on HoloLens 2" you can check "does my device support articulated hands?". That will then work on other platforms that support articulated hands. For an example, check out MixedRealityToolkit.Examples/Demos/Utilities/Scenes/MixedRealityCapabilityDemo.unity in MRTK examples.

If you need a temporary solution for now to differentiate WMR from HL1 from HL2, you can use the following code. Note it's windows-only:

using Windows.Security.ExchangeActiveSyncProvisioning;

EasClientDeviceInformation CurrentInfo = new EasClientDeviceInformation();
string sku = CurrentInfo.SystemSku;

HoloLens 1, HoloLens 2, and Immersive headsets should all return different strings.

It's also possible to check the runtime platform as follows:

if (Application.platform == RuntimePlatform.WSAPlayerARM)
{
     // Running HoloLens 2, most likely.
}

Original post link is here: How do you detect whether your Mixed Reality app is running on HoloLens 1, HoloLens 2 or an immersive headset?

Thanks! Nathan

Nathan - MSFT
  • 331
  • 1
  • 7