ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

fix for e_sqlite3 not found for vsto apps. #553

Closed farzonl closed 7 months ago

farzonl commented 10 months ago

Problem: In issue #552 I identified that VSTO is copying SQLitePCLRaw.core.DLL to C:\Users\username\AppData\Local\assembly\dl3\<HASH_STRINGS>\ SQLitePCLRaw.core.DLL but was not copying e_sqlite3.dll with it. SQLitePCLRaw.core.DLL is expecting to find e_sqlite3.dll in the same directory level as itself or a few levels down from it at <same_path>\runtimes\{os-arch}\native\e_sqlite3.dll For VSTO apps nothing is copying the native dependency over. so e_sqlite3.dll isn't propogated.

The Fix:

using System.Reflection.Assembly.GetExecutingAssembly().CodeBase we can get the original path of the copied over binary. This will be the same path where e_sqlite.dll lives. Using Path.GetDirectoryName We get the path without the base name and build out a path using Path.Combine and the libname.

We define a new flag in NativeLibrary called WHERE_CODEBASE that will let us have a third option for lookup of e_sqlite3 providers.

I'm limiting to just e_sqlite3 Because that is the library used by the App Center C# sdk.

ericsink commented 9 months ago

We've had problems with VSTO for a very long time, and I've never known what was going wrong or how to fix it. Now we have answers, and that's great news.

But now we need to figure how to incorporate the fix without breaking anything else. I'll need to find some time soon to look at this a bit more closely.

farzonl commented 9 months ago

We've had problems with VSTO for a very long time, and I've never known what was going wrong or how to fix it. Now we have answers, and that's great news.

But now we need to figure how to incorporate the fix without breaking anything else. I'll need to find some time soon to look at this a bit more closely.

No worries. I want to do this right. I was looking for ways to handle different versions of .net, and to my suprise I didn't find any usage of Environment.Version and RuntimeInformation.FrameworkDescription in this repo before mine. Thats pretty impressive given the shear number of platforms this projects suports between runtimes, oses, etc.

In anycase I put up the fix I mentioned to @tibel. Pleae let me know how you want to proceed.

farzonl commented 9 months ago

@ericsink Is the use of RuntimeInformation.FrameworkDescription in revision 4 sufficent to satify the concerns here?

ericsink commented 9 months ago

Sorry, I haven't found time to look at this closely yet. But thanks for the nag. I'll try to get it done soon.

farzonl commented 8 months ago

https://github.com/ericsink/SQLitePCL.raw/issues/552#issuecomment-1763379318

No worries Eric.

I wanted to show another way we could do this:

https://github.com/libgit2/libgit2sharp/blob/8c32b6160a49890e26100148e73c1558b0daa9af/LibGit2Sharp/GlobalSettings.cs#L43C1-L68C10

libgit2sharp is creating preprocessor blocks for .netframework. I tested it and it works in VSTO apps aswell.

farzonl commented 7 months ago

@ericsink if it is possible to make a decision on this pr this month that would be ideal for me. I'm not sure what the next semester plan will be for the app I've built after November so can't promise to devote any time to this going forward.