Excel-DNA / Samples

Various sample projects and snippets related to Excel-DNA
MIT License
124 stars 80 forks source link

How to use native libraries when targeting .NET Framework 4.8? #31

Closed altso closed 1 year ago

altso commented 1 year ago

With the latest version of ExcelDna 1.7-rc5 (or even earlier) it is possible to pack native dependencies in a .dna file, but I could not figure out a way to use them in .NET Framework 4.8.

I am using SQLitePCLRaw and e_sqlite3.dll native library. My understanding is that it uses DllImport or similar mechanism to make calls to the native library. The problem is that even though the library is packed and shipped in .dna file, the process still fails with System.DllNotFoundException: Unable to load DLL 'e_sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E). I verified the content of .dna file and see the library there, so it's not related to the packing process.

Does ExcelDna unpack native libraries to a folder when it loads? I know it loads all managed libraries from memory (opposed to file system), but do not know how native libraries are supposed to be handled/loaded. I could not find any examples in Samples repo as well.

Any help is greatly appreciated.

altso commented 1 year ago

Resubmitted as https://github.com/Excel-DNA/ExcelDna/issues/623