Quick answer: DllNotFoundException means a [DllImport] call ran and the operating system could not load the native library behind it. Either the file is not in the build for that platform and CPU, the [DllImport] name does not resolve to it, or one of its own dependencies (often the Visual C++ runtime) is missing. Check the plug-in’s platform settings in the Inspector, confirm the file is in the build, then list its dependencies with dumpbin /dependents, ldd or otool -L.

The plug-in works in the editor, the build finishes without a warning, and then the first call into native code throws. Unity does not load a native library until a script calls one of its functions, so this exception can sit unnoticed behind a feature (voice chat, a store SDK, a save backend) until a player reaches it. The message names the library and almost never says why it failed. This guide covers the forms the message takes, the causes on each platform in order of likelihood, the commands that show which one you have, and the sibling EntryPointNotFoundException.

The exact error

The wording depends on the scripting backend and the Unity version:

DllNotFoundException: MyPlugin

DllNotFoundException: MyPlugin assembly:<unknown assembly> type:<unknown type> member:(null)

DllNotFoundException: Unable to load DLL 'MyPlugin': The specified module could not be found.

DllNotFoundException: Unable to load DLL 'MyPlugin'. Tried the load the following dynamic libraries: Unable to load dynamic library 'MyPlugin' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "MyPlugin" not found

The first two come from Mono (older and newer runtimes). The third is the older IL2CPP form, and the last is what IL2CPP prints in Unity 2022.3 and Unity 6, typo included. On Mono, Player.log usually has several Fallback handler could not load library lines just above the exception, one per path the runtime tried.

All of them mean the same thing: a managed method marked [DllImport("MyPlugin")] was called and loading the native library failed. The name in the message is the string from your attribute, not a file name. One detail explains most of the confusing cases: the operating system reports a library whose dependency is missing with the same error as a library that is missing itself. On Windows both are error 126, “The specified module could not be found”. A plug-in that is sitting right where it should be can still throw this exception.

What causes it

  1. The plug-in’s import settings exclude the platform or CPU you built. The DLL is ticked for Editor only, the .so is set to ARMv7 while the build is ARM64, or the .meta file was never committed and the build machine imported the file with default settings.
  2. A dependency of the plug-in is missing on the machine. The Visual C++ runtime (VCRUNTIME140.dll, MSVCP140.dll), a second DLL from the same SDK, libc++_shared.so on Android, or a system library on Linux. It works on your PC because Visual Studio installed everything.
  3. The plug-in was built in Debug. A Debug build links the debug C runtime (VCRUNTIME140D.dll, ucrtbased.dll), which exists only on machines with Visual Studio and cannot be redistributed.
  4. The name in [DllImport] does not resolve to the file. An extension or lib prefix in the string, a difference in letter case on Linux and Android, or a real library name on a platform that links statically and needs __Internal.
  5. On Android, the library exists for one ABI only. The SDK shipped an armeabi-v7a library, your build includes ARM64, and a 64-bit phone runs the 64-bit half of the app where the library does not exist.
  6. The file is the wrong architecture. A 32-bit DLL in a 64-bit player, or an Intel-only .bundle in an Apple silicon build.
  7. Something removed or blocked the file after you shipped it. Antivirus quarantined an unsigned DLL, or macOS Gatekeeper refused an unsigned or quarantined library. This is the rare one, and it only affects some players.

How a DllImport name becomes a file

Pass the bare library name. The runtime adds the prefix and extension for the platform it runs on.

PlatformFile in the projectDllImport stringWhere it ends up
WindowsMyPlugin.dll"MyPlugin"<Game>_Data\Plugins\x86_64\
macOSMyPlugin.bundle or libMyPlugin.dylib"MyPlugin"<Game>.app/Contents/PlugIns/
LinuxlibMyPlugin.so"MyPlugin"<Game>_Data/Plugins/
AndroidlibMyPlugin.so, one per ABI"MyPlugin"lib/arm64-v8a/ inside the APK
iOS, tvOSstatic library (.a) or source files"__Internal"linked into the executable
WebGL.jslib, or C/C++ source"__Internal"compiled into the build

iOS and WebGL have no separate library to find, so a real name there fails every time. Put the difference in one constant:

// Broken: ties the import to one platform's file name
[DllImport("libMyPlugin.so")]
static extern int mp_init();

// Works everywhere the plug-in exists
#if (UNITY_IOS || UNITY_TVOS || UNITY_WEBGL) && !UNITY_EDITOR
    const string Lib = "__Internal";
#else
    const string Lib = "MyPlugin";
#endif

[DllImport(Lib)]
static extern int mp_init();

How to find which cause is yours

1. Read the log on the failing machine. Player.log is in %USERPROFILE%\AppData\LocalLow\<Company>\<Product>\ on Windows, ~/Library/Logs/<Company>/<Product>/ on macOS and ~/.config/unity3d/<Company>/<Product>/ on Linux. In the editor, Editor.log is more direct. It prints one of these when a plug-in fails:

Plugins: Failed to load 'Assets/Plugins/x86_64/MyPlugin.dll' with error 'The specified module could not be found.'
Plugins: Failed to load 'Assets/Plugins/x86_64/MyPlugin.dll' because one or more of its dependencies could not be loaded.

2. Check the file is in the build at the location in the table above. If it is not there, the cause is import settings. If it is there, the cause is a dependency, the architecture, or something blocking the file.

3. List what the library needs. On Windows, from a Developer Command Prompt:

dumpbin /dependents MyPlugin.dll

  Image has the following dependencies:

    KERNEL32.dll
    VCRUNTIME140.dll
    VCRUNTIME140_1.dll
    MSVCP140.dll
    api-ms-win-crt-runtime-l1-1-0.dll

Names ending in D (VCRUNTIME140D.dll, MSVCP140D.dll) or ucrtbased.dll mean a Debug build. Without Visual Studio, the open-source Dependencies tool shows the same list as a tree and marks the modules it cannot find. dumpbin /headers MyPlugin.dll prints the machine type if you suspect a 32-bit file.

On Linux and macOS:

# Linux: any "not found" line is your missing dependency
ldd MyGame_Data/Plugins/libMyPlugin.so | grep "not found"

# macOS: dependencies, architectures, quarantine flag
otool -L MyGame.app/Contents/PlugIns/MyPlugin.bundle/Contents/MacOS/MyPlugin
lipo -archs MyGame.app/Contents/PlugIns/MyPlugin.bundle/Contents/MacOS/MyPlugin
xattr -l MyGame.app/Contents/PlugIns/MyPlugin.bundle

4. On Android, let the linker tell you. The reason is in logcat, in the dlopen failed text:

adb logcat | grep -i -E "dlopen failed|DllNotFoundException"

dlopen failed: library "MyPlugin" not found
dlopen failed: library "libc++_shared.so" not found: needed by /data/app/.../lib/arm64/libMyPlugin.so
dlopen failed: cannot locate symbol "__cxa_pure_virtual" referenced by "/data/app/.../libMyPlugin.so"
dlopen failed: "/data/app/.../libMyPlugin.so" is 32-bit instead of 64-bit

Then list the libraries that were packaged: unzip -l MyGame.apk "lib/*". You want libMyPlugin.so under every ABI folder present. The guide to reading Unity Android logs with logcat covers filtering in more detail.

Fix 1: correct the plug-in import settings

Select the library in the Project window. In the Inspector, under Select platforms for plugin, tick the platforms that should include it, then set the CPU and OS under Platform settings and click Apply. A Windows DLL needs Standalone with x86_64. An Android .so needs Android with the matching CPU (ARM64 for a file built for arm64-v8a). Editor and Standalone are separate tick boxes, which is how a plug-in ends up working in Play mode and missing from the build.

Unity picks defaults from the folder: a file under Assets/Plugins/x86_64 is assumed to be a 64-bit desktop plug-in, and one under Assets/Plugins/iOS an iOS one. Those defaults apply when there is no .meta file, so commit the .meta next to every native library. A build server that imports the DLL fresh with different settings from yours produces exactly this bug.

Fix 2: ship what the library depends on

Fix 3: cover every Android ABI you build

Compare the ABI folders the plug-in ships with the boxes ticked in Edit > Project Settings > Player > Other Settings > Target Architectures. If ARM64 is ticked, every native plug-in needs an arm64-v8a library whose Inspector CPU is ARM64. A 64-bit phone loads only 64-bit libraries, so a plug-in with just an ARMv7 file fails there and works on old 32-bit devices. Google Play requires the 64-bit build, so the fix is a newer plug-in, not removing ARM64. If the library is present and logcat complains about page alignment on a recent phone, that is the 16 KB page size problem.

Fix 4: stop the file being removed or blocked

On Windows, unsigned DLLs from small vendors are a common antivirus false positive. Code-sign your own native libraries and submit false positives to the vendor. On macOS, sign every .bundle and .dylib inside the app, then notarize the app, so Gatekeeper accepts the plug-in when the game is downloaded outside a store. For Apple silicon, ship a universal library: lipo -archs must print both x86_64 and arm64 if the build target is Intel 64-bit + Apple silicon.

The sibling error: EntryPointNotFoundException

EntryPointNotFoundException: mp_init
EntryPointNotFoundException: Unable to find method for p/invoke: 'mp_init'

Here the library loaded and the function was not in it. The usual reasons: the function was compiled as C++ without extern "C", so its exported name is mangled; it was never exported (__declspec(dllexport) on Windows, default visibility elsewhere); the C# name or EntryPoint has a typo; or an older copy of the library with the same name was loaded first. List the exports and compare them with your declarations:

dumpbin /exports MyPlugin.dll
nm -D --defined-only libMyPlugin.so
nm -gU MyPlugin.bundle/Contents/MacOS/MyPlugin

What to tell players

  1. Verify the game files (Steam: Properties > Installed Files > Verify integrity of game files) and restore anything the antivirus quarantined.
  2. On Windows, install or repair the Microsoft Visual C++ 2015–2022 Redistributable (x64).
  3. Do not move the executable out of its folder. It needs the _Data folder beside it.
  4. Send the Player.log file if it still fails.

How to confirm the fix

Run the shipped build on a machine that has never had Visual Studio or the SDK installed: a clean Windows VM, a second Mac, a stock Linux install, a 64-bit Android phone. Call every native feature once at startup in a development build so a missing library fails in the first minute instead of behind a menu. In CI, compare the plug-in folder of the build against a list of expected files.

Seeing it from players’ machines

This exception is thrown inside a running game, so it is one Bugnet can report. The Unity SDK files each logged exception with its stack trace and recent log lines, and every report carries the platform, OS version, CPU and game version. That is what separates “every Windows player without the Visual C++ runtime” from “64-bit Android only”. Reports with the same title stack into one entry with an occurrence count, so a plug-in missing from one build shows up as a single bug with a number beside it.

What it cannot do is name the missing dependency. That still takes dumpbin, ldd or logcat on an affected machine. And if the failure is early enough that the game never starts, there is no report at all.

Frequently asked questions

Why do I get DllNotFoundException when the DLL is in the Plugins folder?

Most often the DLL was found but one of its own dependencies was not, and the operating system reports both cases with the same error. List the dependencies with dumpbin /dependents on Windows, ldd on Linux or otool -L on macOS, and check for the Visual C++ runtime or a second SDK library.

Why does the plug-in work in the Unity editor but not in the build?

The plug-in’s import settings include the Editor and exclude the build platform or CPU, so Unity never copies it into the player. Select the file, tick the target platform under Select platforms for plugin, set the CPU, and click Apply. Also commit the .meta file.

What name should I pass to DllImport in Unity?

The library name without a prefix or extension, such as MyPlugin for MyPlugin.dll, libMyPlugin.so or MyPlugin.bundle. On iOS, tvOS and WebGL, where native code is linked into the executable, use the special name __Internal instead.

Why does DllNotFoundException only happen on some Android phones?

The plug-in probably ships a library for one ABI only. A 64-bit phone loads only arm64-v8a libraries, so a plug-in with just an armeabi-v7a file fails there and works on 32-bit devices. Check the lib folders inside the APK and the dlopen failed line in logcat.

What is the difference between DllNotFoundException and EntryPointNotFoundException?

DllNotFoundException means the native library, or something it depends on, could not be loaded. EntryPointNotFoundException means the library loaded but has no exported function with that name, usually because of C++ name mangling, a missing export or an outdated copy of the library.

The library named in the exception is often present and fine. Before moving files around, list what that library itself depends on, on a machine without your development tools.