I came into some frustrating issue today in the editor : I have a project in which I have manually imported libraries. All of the required dependencies are also in the project, in a subfolder (see screenshots below).
This project was working fine and finding everything it needed. Today I downloaded the new version of the libraries, replaced DLLs without changing any of the folder structure, and suddendly, with two different libraries (libSkiaSharp and pdfium from SkiaSharp and PDFToImage), when I hit play i have a “DLLNotFoundException” on the dependencies, but only if they are in a subfolder…
I have many dlls and .so because this is a cross-platform project (android ARM64 + android x64 + UWP ARM64 + Winx64), so putting every single dependency dll in the same folder is a no-go.
Anyone knows why this happens ?
Thanks.
Here are the screenshots :
Working old project structure, this exact same structure on the updated dlls doesn’t work, and I have to put libskiasharp.dll in the root Skia folder :
Have you done this before? Because I wonder whether you may have deleted the Inspector settings (.meta file) for those and thus the platform compatibility settings may be incorrect. Or perhaps the new DLL is not built the same way as the previous, eg the targeted .NET framework has changed or it’s a release vs debug build, that sort of thing.
In any case, with such an issue it’ll be worthwhile to try and delete the Library, Obj and Temp folders (close the editor before doing that).
Yes we have been updating dlls this way for a while now, we never encountered this.
I’ve already tried deleting these folders, and nothing worked. Also, platform compatibility is correct since moving the dll to the root folder works. And we encoutered this with two dlls made by two different people, so I don’t suspect an internal change ?
Update : the issue is even weirder : it actually can’t find the dll anywhere on each project startup until I move the dll file to a different folder ?? But no matter the folder :
I have my dll in a Skia/win-64/native subfolder.
I open the Unity project, click play : DLLNotFound
I ctrl+x the dll, put it in Skia/ folder.
hit play, it works
I close the editor
I open the Unity project again
I hit play : DLLNotFound
I ctrl+x the dll, put it in Skia/win-64/native subfolder
Did you use the net462 version of SkiaSharp and net462/net471/net481 version of PDFtoImage? In that case, I suspect the issue could be to do with how SkiaSharp includes its own optional logic for loading libraries (with conditional compilation here), and this was brought over to PDFtoImage (with conditional compilation here). The .NET Framework versions of SkiaSharp and PDFtoImage use the custom library resolution logic and not a simple DllImport (DllImport being, to my knowledge, supported in Unity as the default way to reference native libraries) which could be causing your problem. The netstandard2.1 version of SkiaSharp and netstandard2.0 version of PDFtoImage (current Unity releases being compatible with netstandard2.1) use normal DllImport, perhaps try using these versions of the libraries if you aren’t already. The Unity package provided by PDFtoImage uses the .NET Standard implementations, which as stated works for me.
I am on netstandard versions of both. I can’t use the unity package version, as this is for a project that needs to be exported as a unitypackage internally, and so every used lib needs to be in assets folder.
This really doesn’t sound like expected behavior at all. Would you be comfortable with sharing a cut-down Unity project with the bare minimum that reproduces this issue?
Up, clean project doesn’t work either. Here is a cut-down project. You will have nullrefs as i removed some scripts, but you can still see the “DllNotFoundException: libSkiaSharp assembly:<unknown assembly> type:<unknown type> member:(null)” exception on start.