Application looks for plugins in "[ProjectName]_Data/Mono" or "[ProjectName]_Data/MonoBleedingEdge"

When I build my project (Windows standalone) and run it on my PC, everything works fine. However, on some other PCs, a native plugin (which I wrote) used in the project fails to load with the message:

Fallback handler could not load library [Path to build directory]/[ProjectName]_Data/Mono/[Plugin Name].dll

However, this “Mono” directory under the data folder doesn’t exist, and the plugin and its dependencies are in the [Project Name]_Data/Plugins/x86_64 directory as always.

I believe this issue is the same as described in Missing Mono folder in build . I have already tried a clean checkout, rebuilding the library, and reinstalling Unity. It still works on some PCs but not others (and on PCs where it fails, it fails across all user accounts and it fails consistently every single time the application is run). This was with Unity 2020.3.23f1.

I also tried upgrading the Unity version to 2021.3.16f1. The same problem occurs, except that instead of [ProjectName]_Data/Mono it looks for the plugin in [ProjectName]_Data/MonoBleedingEdge, which also does not exist.

Has anyone experienced this problem before or know what causes it? Earlier versions of this project worked as expected on the PCs in question and it is unclear to me where to start looking for the change that broke it.

1 Like

It will look in those folders if loading the from the regular location fails. The fact that it works on your machine but not on some other machines suggests to me that your native plugin depends on another DLL (most likely dynamically linker Visual C++ runtime) that you didn’t include with the plugin and it just happens to be installed on your system.

You can check what other DLLs your plugin depends on with Dependencies: Releases · lucasg/Dependencies · GitHub

We already checked for missing dependencies–all clear. In addition, if we substitute the entire [Project Name]_Data folder from the non-working build into an older, working build located on the same PC, the application runs as expected (the dll loads correctly), so I don’t think there is a dependency missing.

Would you be able to share the [Project Name]_Data/Plugins folder of a non-working build?

Do you have access to a computer where it doesn’t work in order to do some debugging?

I cannot share the Plugins folder. I do have access to a computer where it doesn’t work. For now, we were able to resolve the problem by removing a dependency of the native plugin, though it’s unclear why that worked since the dependency is in the [Project Name]_Data/Plugins folder anyway.

If you can reproduce it, you can enable “loader snaps”, which is basically the Windows DLL loader dumping all diagnostics information into the debugger output:

  1. Install Windows SDK with “Debugging tools for Windows” component from Windows SDK - Windows app development | Microsoft Developer on a computer where you cannot reproduce it (installing Windows SDK might change the reproducibility);
  2. Go toC:\Program Files (x86)\Windows Kits\10\Debuggers\x64, find gflags.exe and copy to a machine where the issue is reproducible;
  3. Open admin command prompt
  4. Type “gflags.exe -i <game_exe_name>.exe +sls”. Note that “<game_exe_name>” is just the name, not the full path to the executable;
  5. Run the game under a debugger. Either a Visual Studio remote debugger or WinDbg downloaded from the Windows Store would do (do not install Visual Studio on the machine as it can also affect reproducibility).
  6. Look at the debugger output. It should tell you exactly why it cannot load the DLL.
  7. When done, disable loader snaps with “gflags.exe -i <game_exe_name>.exe -sls”.

I’ve builded a Windows standalone version, trying to run it with gflags, which not immediately worked, but instead I mentioned that in the Player.log I find

Fallback handler could not load library C:/Users/mgoemmel/Desktop/outWin/True Backgammon_Data/MonoBleedingEdge/bgblitz_win.dll

Fallback handler could not load library C:/Users/mgoemmel/Desktop/outWin/True Backgammon_Data/MonoBleedingEdge/bgblitz_win.dll
DllNotFoundException: bgblitz_win.dll assembly: type: member:(null)

while in my project directory the dll is located at

C:\Users\mgoemmel\Desktop\outWin\True Backgammon_Data\Plugins\x86_64\bgblitz_win.dll

I guess this would be the reason that the dll could not be loaded. Any ideas what I’m doing wrong here?

Thanks and regards

Markus

You need to run under a debugger to see gflags output. It will not show up in the log.