Using Contrib in ExcelDna

Feb 26, 2009 at 2:50 PM

We recently had the following discussion on the ExcelDna google groups. If anyone has worked on something similar please let me know your comments. Thanks...

I just recently looked at the functions under the ExcelDna Contrib
library and think they can be very useful. I have encountered one
problem though. Is there a way to combine Contrib with the source code
of ExcelDna in such a way that after adding it to ExcelDna and
recompiling it all the functions within the "Contrib" project will now
be a part of ExcelDna so that in Excel when i add the ExcelDna.xll
adding I can access all the functions there.

Please let me know if that can be done.

Thank You.


On Feb 19, 11:26 pm, KevinT <> wrote:

If you would like the Contrib functions to be exposed in Excel simply
include a reference to the dll in your .dna file like so:

    <ExternalLibrary Path="MyOwnLib.dll" />
    <ExternalLibrary Path="ExcelDna.Contrib.dll" />

If you would like to use the Contrib API directly from your own
project, just include a reference to it from your project.

Does that answer the question, or did I misunderstand you?

Hi Kevin,
I have actually done that in the past without problems. But what I
want to know is if I copy the contrib funtions into the ExcelDna
project file and then recompile it can I then access those functions
just by adding ExcelDna.xll in Excel. I already tried this and I am
having some trouble. I am able to copy the files from Contrib (such as
Cachefunctions.cs, RangeUtilities.cs etc.) into the ExcelDna project
and compile it without errors but then when i add the newly created
ExcelDna.xll file into Excel it doesnt recognize the functions from
the contrib project.

Is there a way to do this. Please let me know. Any help will be

Thank You,


This won't work easily at the moment, since the .xll is not a
managed .NET assembly, so those functions aren't found and registered
automatically. So you'd have to add some more code in ExcelDna to get
this right.

On the longer-term to-do list, I plan to add a pack-and-go kind of
feature, where .dna files, and some .dll libraries could be added as
resources into the .xll file, and then automatically loaded and
registered at runtime. So you'd redistribute a single .xll file. Some
of the plumbing for this is in place already (this is what I do with
the ExcelDna.Loader and ExcelDna.Integration assemblies). However,
adding your library to be loaded would take some more work too. If you
like the idea, you might like to add it as an issue on CodePlex.