I am running private registry server(veldaccio). And uploaded a package with native dll.
When I try to load the dll file in c# script in Assets … with LoadLibrary function below, It fails.
[DllImport(“kernel32”)] public static extern IntPtr LoadLibrary(string path);
If I make it as embedded package (located at Packages). It loads well.
Does someone have any idea, how to resolve this issue?
Greetings!
It could be that when you call LoadLibrary, you’re passing a relative path "Packages\<their-package-name>\path\to\dll"
, which is relative to their project path.
However with packages that are downloaded from a registry, this virtual path works within Unity (it gets remapped to the right location on disk) but not with external tools.
I’d suggest making the path to the DLL absolute before calling LoadLibrary by using System.IO.Path.GetFullPath("Packages\<their-package-name>\path\to\dll")
and passing the result to “LoadLibrary”.
Let us know if you have any questions 