SQLitePCL.raw icon indicating copy to clipboard operation
SQLitePCL.raw copied to clipboard

Support loading of e_sqlite3.dll from output root directory

Open ghost opened this issue 6 years ago • 4 comments

Currently e_sqlite3.dll is only loaded from runtimes sub-directory. But nuget copies native dlls from runtimes folder to the output root folder during build if a runtime identifier is specified.
So the dll exists in the output root directory but is never loaded from there.

ghost avatar Oct 17 '19 10:10 ghost

On a related note, if the Platform is x86, AnyCPU with Prefer32Bit, or x64, you really only need one dll in the output directory

bricelam avatar Oct 17 '19 15:10 bricelam

The familiar and tired feeling I have when I read the two comments above is, "Yep, that seems correct, but if I make a change, I bet something will break, probably with Mono."

For each of these comments, my question is "In which cases is this true?"

.NET Framework? .NET Core? .NET Core pre-3.0? Mono?

ericsink avatar Oct 17 '19 15:10 ericsink

Also, the runtimes folder will only work on newer versions on NuGet.

lol, I’d probably have too much FUD to change anything too

bricelam avatar Oct 17 '19 15:10 bricelam

I'm sorry for not giving any further details, just didn't thought in this dimension.

I have this problem on .NET Framework. I tested it with with .NET Core 3.0 and there the runtime folder is not copied to output just the e_sqlite3.dll in the output root and it is also loaded from there.

I've dived a bit into the source and I think this is actually a bug on .NET Framework.

Both versions of Batteries_V2.Init method call NativeLibrary.Load with flags = 2 parameter but in .NET Core the flags is converted to a DllImportSearchPath enumeration where 2 means AssemblyDirectory and on .NET Framework the value is interpreted as "search in runtimes directory" within MakePossibilitiesFor method.

ghost avatar Oct 18 '19 04:10 ghost