Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[HoloLens] Unable to load native plugin in Release configuration

Discussion in 'VR' started by xweix, Oct 12, 2016.

  1. xweix


    Sep 12, 2016
    I created a Universal Windows DLL and use it as a native plugin in my Unity project (5.4.0f3-HTP, il2cpp scripting backend). It works well when running the Debug configuration in the HoloLens emulator (10.0.14393.0). But the same native plugin could not be loaded when I launch the Release build. And I found the plugin (RoarApi.dll) got unloaded, while the other native DLLs loaded successfully:

    'xxx.exe' (Win32): Loaded 'C:\Windows\System32\WinMetadata\Windows.UI.winmd'. Module was built without symbols.
    'xxx.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Graphics.dll'. Symbols loaded.
    'xxx.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\client-unityVS.Release_Win32.xwei\RoarApi.dll'. Symbols loaded.
    'xxx.exe' (Win32): Unloaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\client-unityVS.Release_Win32.xwei\RoarApi.dll'

    'xxx.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\client-unityVS.Release_Win32.xwei\MicStreamSelector.dll'. Cannot find or open the PDB file.

    This is the corresponding log when running Debug configuration. Everything looks correct there:

    'xxx.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Graphics.dll'. Symbols loaded.
    [0.007285 / 0.269215] - AppCallbacks::SetCoreWindowEvents
    Loading native plugins
    Loading RoarApi.dll
    'xxx.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\client-unityVS.Debug_Win32.xwei\RoarApi.dll'. Symbols loaded.

    Loading MicStreamSelector.dll
    'xxx.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\client-unityVS.Debug_Win32.xwei\MicStreamSelector.dll'. Cannot find or open the PDB file.
    'xxx.exe' (Win32): Loaded 'U:\Programs\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.24210.0_x86__8wekyb3d8bbwe\vccorlib140_app.dll'. Symbols loaded.
    'xxx.exe' (Win32): Loaded 'U:\Programs\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.24210.0_x86__8wekyb3d8bbwe\msvcp140_app.dll'. Symbols loaded.
    'xxx.exe' (Win32): Loaded 'U:\Programs\WindowsApps\Microsoft.VCLibs.140.00.Debug_14.0.24210.0_x86__8wekyb3d8bbwe\vcruntime140_app.dll'. Symbols loaded.
    Loading SharingClient.dll
    'xxx.exe' (Win32): Loaded 'U:\Users\DefaultAccount\AppData\Local\DevelopmentFiles\client-unityVS.Debug_Win32.xwei\SharingClient.dll'. Cannot find or open the PDB file.

    I traced deeper into the problem. It seems the failure comes from LibraryLoader::LoadDynamicLibrary(), where ::LoadLibraryW() didn't load the DLL successfully. GetLastError() return 0x7e, which is "The specified module could not be found". But there was no error in the deployment.

    Any help would be very appreciated.
  2. Tautvydas-Zilys


    Unity Technologies

    Jul 25, 2013
    You probably built your DLL in debug configuration. Building it in debug makes it depend on DLLs from debug C runtime. Visual Studio does not package these DLLs with the UWP application if you build it in release or master configurations - it only does so for debug configurations. Therefore, debug builds of native plugins work only in debug builds on UWP. Build the plugin in release mode, and everything should work just fine (release builds of plugins work in debug UWP application builds too).
  3. xweix


    Sep 12, 2016
    Yes, that's the exact problem. The UWP application can now be launched by deploying the Release build of the DLL.

    Thank you so much for your help, Tautvydas!:D