Search Unity

Loading a UWP DLL

Discussion in 'VR' started by j2inet, Jun 14, 2016.

  1. j2inet

    j2inet

    Joined:
    Jul 15, 2015
    Posts:
    7
    There's some functionality I needed to invoke in a HoloLens application.

    I've added the DLL to my assets folder and added a reference to the DLL using the Mono editor. When I try to Build the project in Unity I get the following error.

    "Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded"

    Any ideas in how to address this?



    Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.

    at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)

    at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0

    at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0

    at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0

    at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0

    at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0

    at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0

    at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0

    The following assembly referenced from C:\Users\Joel\Documents\Unity\Projects\MqttTest\Assets\M2Mqtt.UWP.dll could not be loaded:
    Assembly: System.Runtime (assemblyref_index=0)
    Version: 4.0.20.0
    Public Key: b03f5f7f11d50a3a
    The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (C:\Users\Joel\Documents\Unity\Projects\MqttTest\Assets\).

    Could not load file or assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
    Missing method .ctor in assembly C:\Users\Joel\Documents\Unity\Projects\MqttTest\Assets\M2Mqtt.UWP.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
    Can't find custom attr constructor image: C:\Users\Joel\Documents\Unity\Projects\MqttTest\Assets\M2Mqtt.UWP.dll mtoken: 0x0a00000e
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Click on the DLL inside Unity, and mark it as compatible with Windows Store .NET scripting backend only (the editor checkbox should be switched off).
     
    j2inet likes this.
  3. j2inet

    j2inet

    Joined:
    Jul 15, 2015
    Posts:
    7
    Thanks, that was it!