In the last two posts, we learned how we could use native libraries. When searching for a library to load, a few candidates are checked before it throws a DllNotFoundException.
If we specify in the code that we would like to load "test" 1️⃣, it will check a couple more: test.so, libtest.so, and test. We can see those in the exception output if the resolution fails 3️⃣. Only after all of those are not found will it throw an exception, causing our application to crash.
If needed, we can also attach our own resolver using NativeLibrary.SetDllImportResolver 2️⃣, which allows us to perform the resolution ourselves. One resolver per assembly can be registered with this method.
Docs 📑: https://learn.microsoft.com/en-us/dotnet/standard/native-interop/native-library-loading
#dotnet #platforminvoke #libraryimport #librarynameresolution
---
If you find this useful, consider giving a like & share ♻