Packing SQLite with ExcelDNA

673 views
Skip to first unread message

Cameron Twigden

unread,
Nov 24, 2013, 10:59:13 PM11/24/13
to exce...@googlegroups.com
I've implemented a SQLite DB which is used by my add-in (C# .NET 4.5). This works fantastically. I can copy the files (DLLs, exceldna configs, the sqlite xml file, etc) to any location on any machine, and everything still works.

My problem strikes when I pack the add-in. I'm struggling to get the SQLite to work when I run from a packed version of the add-in;and I haven't been able to find any examples of the .dna file to show the referencing. What I've currently ended up with is:

<Reference AssemblyPath="System.Data.SQLite.dll" Pack="true" />
<File Path="System.Data.SQLite.xml" Pack="true" />

I've had to use "File" for the XML reference, as otherwise the add-in fails to load as it believes the XML is invalid. I've also tried using "Path" instead of "AssemblyPath".

Any guidance would be much appreciated, or even a sample from someone who has implemented SQLite within an ExcelDNA add-in.

Many thanks in advance!

Govert van Drimmelen

unread,
Nov 25, 2013, 6:38:22 AM11/25/13
to exce...@googlegroups.com
Hi Cameron,

Is your System.Data.SQLite the mixed assembly, or are you shipping the native .Interop.dll separately.

Currently the Excel-DNA packing does not support mixed or native libraries. This is due to a restriction of the in-memory loading of assemblies in .NET. To support this we'd have to write the library to a file somewhere, then clean up reliably when done. And manage the loading so that the temporary assembly is found. I've not had the courage to look into all of this.

The <File> tags will not create the file in the directory either - it's only use is to allow you to pack source code directly in the .dna file, to be compiled at runtime. So it's not a general purpose file packing feature of any sort.

You can take control of all of this yourself, by storing these dependencies as resources in your compiled assembly, and then extracting and loading at runtime.
But you've reached the end of the (current) built-in support.

Regards,
Govert

Cameron Twigden

unread,
Nov 25, 2013, 6:48:29 PM11/25/13
to exce...@googlegroups.com
Many thanks Govert. 

At least I now know why it wasn't working for me. I've now implemented the resources as part of the assembly.

Many thanks
C

Barney Dalton

unread,
Feb 10, 2015, 4:47:56 AM2/10/15
to exce...@googlegroups.com
Hi,
I have just come across this thread as I am also trying to include SQLite functionality in an Excel DNA addin. Has anything changed or does this still represent the status quo? If so, where should I look for the best guidance on how to get SQLite working with an Excel DNA addin? Does anyone perchance have some sample code showing how to manage it as a resource within the assembly?
Thanks,
Barney

Govert van Drimmelen

unread,
Feb 11, 2015, 4:49:40 PM2/11/15
to exce...@googlegroups.com
Hi Barney,

The limitation that ExcelDnaPack only supports managed assemblies remains.

You might investigate the Costura.Fody project (https://github.com/Fody/Costura) to do the mixed library embedding. I have no experience with it myself.
If you try it, please let us know how it goes.

Cheers,
Govert

Barney D

unread,
Feb 12, 2015, 4:19:40 PM2/12/15
to exce...@googlegroups.com
Thanks Govert,
I'm afraid I'm going to be lazy and pursue a different route that doesn't depend on SQLite for now.
Barney

Samuel Carrier

unread,
Nov 20, 2016, 9:18:24 PM11/20/16
to Excel-DNA
Is it still the case that it's not possible to pack sqlite?
Thank you

Govert van Drimmelen

unread,
Nov 21, 2016, 4:34:52 AM11/21/16
to exce...@googlegroups.com

There is no change with packing native or mixed assemblies yet.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages