Search Unity

Runtime error - Hololens: FileLoadException: Could not load file or assembly 'System.Runtime.Windows

Discussion in 'VR' started by longda, May 8, 2017.

  1. longda

    longda

    Joined:
    Dec 13, 2014
    Posts:
    9
    Quick background:
    I'm making a simple Unity app utilizing the org.webrtc library from nuget. I have this packaged up as a plugin going into Unity from Visual Studio. After building in Unity, I then take the output Visual Studio solution and push the build directly to my hololens.

    In the debug window, I get the following error. This seems like it cannot access the System.Runtime.WindowsRuntime.dll from Hololens but I'm not sure why exactly. I understand the build can't locate the dll but I"m not sure why.

    It seems reasonable that these libs should be available no problem on a windows stack, in Hololens - but maybe I'm missing something. Any help is appreciated.


    Here's error output:

    testing web rtc...

    (Filename: C:/buildslave/unity/build/artifacts/generated/Metro/runtime/DebugBindings.gen.cpp Line: 51)


    'HololensAppUnity.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\HololensAppUnityVS.Debug_x86.username\Org.WebRtc.winmd'. Module was built without symbols.
    'HololensAppUnity.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\HololensAppUnityVS.Debug_x86.username\Org.WebRtc.winmd'. Module was built without symbols.
    NETFX_CORE || UNITY_WINRT
    'HololensAppUnity.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\HololensAppUnityVS.Debug_x86.username\Org.WebRtc.dll'. Cannot find or open the PDB file.
    'HololensAppUnity.exe' (Win32): Loaded 'U:\Programs\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.25019.0_x86__8wekyb3d8bbwe\vccorlib140_app.dll'. Symbols loaded.
    'HololensAppUnity.exe' (Win32): Loaded 'U:\Programs\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.25019.0_x86__8wekyb3d8bbwe\msvcp140_app.dll'. Symbols loaded.
    'HololensAppUnity.exe' (Win32): Loaded 'C:\Windows\System32\mfreadwrite.dll'. Symbols loaded.
    Exception thrown at 0x76D324C2 (KernelBase.dll) in HololensAppUnity.exe: 0x40080201: WinRT originate error (parameters: 0x80070005, 0x00000013, 0x042AF028).
    The thread 0xcc0 has exited with code 0 (0x0).
    Exception thrown at 0x76D324C2 (KernelBase.dll) in HololensAppUnity.exe: 0x40080201: WinRT originate error (parameters: 0x80070005, 0x00000013, 0x091FEBB0).
    Exception thrown at 0x76D324C2 (KernelBase.dll) in HololensAppUnity.exe: 0x40080201: WinRT originate error (parameters: 0x80070005, 0x00000013, 0x00FFEEB0).
    Exception thrown at 0x76D324C2 (KernelBase.dll) in HololensAppUnity.exe: 0x40080201: WinRT originate error (parameters: 0x80070005, 0x00000013, 0x042AEE68).
    'HololensAppUnity.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Networking.dll'. Symbols loaded.
    'HololensAppUnity.exe' (Win32): Loaded 'C:\Windows\System32\FirewallAPI.dll'. Symbols loaded.
    'HololensAppUnity.exe' (Win32): Loaded 'C:\Windows\System32\fwbase.dll'. Symbols loaded.
    Exception thrown at 0x76D324C2 in HololensAppUnity.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x0950C834.
    Exception thrown at 0x76D324C2 in HololensAppUnity.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
    Exception thrown at 0x76D324C2 in HololensAppUnity.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
    Exception thrown at 0x76D324C2 in HololensAppUnity.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
    Exception thrown: 'System.IO.FileLoadException' in System.Private.CoreLib.ni.dll
    'HololensAppUnity.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\HololensAppUnityVS.Debug_x86.username\System.Diagnostics.StackTrace.dll'.
    'HololensAppUnity.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\HololensAppUnityVS.Debug_x86.username\System.Diagnostics.StackTrace.dll'. Symbols loaded.
    FileLoadException: Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    at HololensAppUnityPlugin.Client.WebSocketClient.<initializeWebSocket>d__4.MoveNext()
    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
    at HololensAppUnityPlugin.Client.WebSocketClient.initializeWebSocket()
    at HololensAppUnityPlugin.Client.SessionManager..ctor()
    at HololensAppUnityPlugin.Client.SessionManager.get_Instance()
    at HololensAppUnityPlugin.Client.SessionManager.WebRtcInitialize()
    at Tests.TestWebRtc()
    at Tests.Start()
    at Tests.$Invoke0Start(Int64 instance, Int64* args)
    at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
    (Filename: <Unknown> Line: 0)
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    I would check to see if using that dll is supported on UWP apps, that could be the issue.
     
  3. longda

    longda

    Joined:
    Dec 13, 2014
    Posts:
    9
    Thanks Wesley! Does there happen to be a page in the Unity documentation that outlines that? I came across something along that linked out to MSDN but I haven't been able to locate it again.
     
  4. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    There isn't on Unity, the documentation would be on the Microsoft site.
     
  5. longda

    longda

    Joined:
    Dec 13, 2014
    Posts:
    9
  6. longda

    longda

    Joined:
    Dec 13, 2014
    Posts:
    9
    We can actually load a UWP app with this lib on hololens but we currently can't get it to work inside Unity on hololens.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you make a sample project that uses it and throws that error and report a bug to us with it attached?
     
  8. longda

    longda

    Joined:
    Dec 13, 2014
    Posts:
    9
    @Tautvydas-Zilys Good idea! I just submitted a report with the project attached. Same title as this thread. Thanks in advance!
     
  9. longda

    longda

    Joined:
    Dec 13, 2014
    Posts:
    9
  10. RobJellinghaus

    RobJellinghaus

    Joined:
    Jul 10, 2017
    Posts:
    17
    I am having exactly the same error. But I am not on HoloLens. I am writing a Unity app, compiling and building for UWP, that is trying to dispatch to the UWP CoreDispatcher:

    _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
    {
    await InitializeAsync();
    });

    That method is being run from a Unity component's Start(). It is able to run that line of code, but evidently when it comes time to actually execute it, it tries and fails to load Windows.Runtime. I get a development console message, attached:

    Unhandled 'Platform.COMException' exception caught! - 'The text associated with this error code could not be found.

    Could not load file or assembly 'System.Runtime.WindowsRuntime, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'. Sender: '<null>'. Missing try/catch blocks.

    As near as I can tell, this is bang on the same error you are having, which points to this being an issue with the UWP integration in general rather than anything HoloLens-specific.

    I will track down the issue you reported and add this note to it. I will also start dorking around with App.config to see if I can get it to be happy with the version of Windows.Runtime that is available.

    I tried intercepting this exception with Unity's Application.logMessageReceived event, but I could not, which is frustrating; I would love to look at the actual exception and get more details on exactly what assembly it located. Is there any other way to break into the debugger when Unity catches such an unhandled exception? Setting VS2017 to break when Platform.COMException is thrown didn't work either, which was almost even more surprising.

    Edit: @longda I was unable to find the bug report you filed. Can you please share a direct link to it? I searched for "WindowsRuntime" in the issue tracker, but didn't see your report.
     

    Attached Files:

    Last edited: Jul 10, 2017
  11. RobJellinghaus

    RobJellinghaus

    Joined:
    Jul 10, 2017
    Posts:
    17
    @longda posted this question on the HoloLens forums and got an answer:

    https://forums.hololens.com/discuss...-load-system-runtime-windowsruntime-on-device

    "In the NuGet package manager for my plugin project I downgraded the Microsoft.NETCore.UniversalWindowsPlatform package to version 5.0.0. This is the same version that the exported solution from Unity will use."

    That indeed worked for me -- one of the UWP-specific projects in my solution was using version 5.2.2 of the Microsoft.NETCore.UniversalWindowsPlatform package. Downgrading it to version 5.0.0 solved this WindowsRuntime loading issue.