Search Unity

Windows.Storage is missing when building for UWP (Hololens)

Discussion in 'VR' started by Bocci, Jul 20, 2018.

  1. Bocci

    Bocci

    Joined:
    Sep 7, 2013
    Posts:
    15
    Hi,
    I'm building an app for Hololens and I have the following error:

    error CS0234: The type or namespace name 'Storage' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)

    From my understanding it should be available for UWP (https://docs.microsoft.com/en-us/uwp/api/windows.storage) and there are multiple resources indicating that it's available when building for Hololens.

    System.Windows has only Input and Markup as additional classes.

    I'm on 2017.4.3 but have the same issue with 2018.2
    Scripting runtime version: .NET 4.6 experimental
    Backend: .NET
    Compilation Overrides: Net Core
    VS2017 (up to date)
    My code is enclosed with #if NETFX_CORE (tried UNITY_WSA, WINDOWS_UWP but same error)

    It's been 2 days that I'm trying to understand why it's missing but I'm running out of ideas, could someone give me some suggestions because I don't understand why it's not available.

    Thanks
     
  2. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    407
    Hi Bocci,

    I believe the answer is in the error message: 'System.Windows.Storage' doesn't exist and instead you want 'Windows.Storage'.

    The 'System.Windows' and 'Windows' namepaces are very different. The former is part of .NET and the root namespace for WPF, the old UI framework from Vista and Win7. The later is the root namespace for WinRT, the primary API for UWP apps.

    When developing in C#, both the old .NET libraries and the newer WinRT APIs are made available since WinRT is "projected" into the language. The projection makes WinRT look a lot like .NET but it's completely different, and unfortunately leads to this kind of confusion.
     
  3. Bocci

    Bocci

    Joined:
    Sep 7, 2013
    Posts:
    15
    Thanks a lot for the clear reply timke.

    That's really something I didn't understand, now I get it.