Referencing a library

686 views
Skip to first unread message

Homero

unread,
Feb 14, 2011, 5:15:52 PM2/14/11
to Excel-DNA
Hi,

I'm having a problem with reference.

I have created an addin (let's call it FirstAddin.dll) that runs
properly in excel with its .xll and .dna file.

Then, afterwards, I created another .dll (let's call it
SecondAddin.dll) that uses a function of FirstAddin.dll (with
reference set at the C# code). And the .dna file was like this:
<DnaLibrary RuntimeVersion="v4.0" ShadowCopyFiles="true">
<ExternalLibrary Path="C:\CompletePath\SecondAddin.dll" />
</DnaLibrary>

When I tried to use it at excel, nothing happened. And it didn't stop
at the debug breakpoint I set either. But, if I comment the line where
I use the function of FirstAddin.dll everything runs properly.

Then, I tried to put the reference in the .dna file like this:
<DnaLibrary RuntimeVersion="v4.0" ShadowCopyFiles="true">
<Reference Path="FirstAddin.dll"/>
<ExternalLibrary Path="C:\CompletePath\SecondAddin.dll" />
</DnaLibrary>

But I got the same result.

Then I tryed to pack them into a single .xll using this code:
<DnaLibrary RuntimeVersion="v4.0" ShadowCopyFiles="true">
<Reference Path="FirstAddin.dll" pack="true"/>
<ExternalLibrary Path="C:\CompletePath\SecondAddin.dll" />
</DnaLibrary>

I get this result of packing:
C:\CompletePath>ExcelDnaPack.exe SecondAddin.dna /
Y
Using base add-in SecondAddin.xll
-> Updating resource: Type: ASSEMBLY_LZMA, Name:
EXCELDNA.INTEGRATION, Length
: 37902
-> Updating resource: Type: DNA, Name: __MAIN__, Length: 422
Completed Packing SecondAddin-packed.xll.

But the same thing happen:. I can't use my function on the FirstAddin.

I've also tried putting the complete path of FirstAddin.dll, to change
Reference Path for Reference Name and for Reference AssemblyPath, but
nothing helped.

I don't know what else to do. Can you help me with this?

Regards,

Homero

Tjaart van Wijck

unread,
Feb 15, 2011, 6:32:00 AM2/15/11
to exce...@googlegroups.com

Homero,

The first thing I can think of is to check that the second add-in has a 'using' statement for the first.

Regards,
Tjaart


--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To post to this group, send email to exce...@googlegroups.com.
To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exceldna?hl=en.

Homero

unread,
Feb 15, 2011, 2:03:46 PM2/15/11
to Excel-DNA
Tjaart,

I have already put the 'using' statement referencing the second addin,
or the dll wouldn't even compile.

I don't know if this changes anything (I don't think so), but the
function I'm trying to use is an extension method (especifically of
ExcelReference).

Any other idea?

Regards,

Homero

Govert van Drimmelen

unread,
Feb 15, 2011, 4:59:17 PM2/15/11
to Excel-DNA
Hi Homero,

Your packing does not pack FirstAddIn.dll because xml attributes are
case sensitive, and you need to say Pack="true" with a capital 'P'.
(Sorry - we really need a configuration tool that will eliminate these
kind of errors. Any volunteers?)

But that's not your initial question...
Are you trying to make a single add-in exposing both FirstAddIn.dll
and SecondAddIn.dll?
In this case you can just put both into the TheAddin.dna file as
ExternalLibraries:

<DnaLibrary RuntimeVersion="v4.0" ShadowCopyFiles="true">
<ExternalLibrary Path="FirstAddin.dll" />
<ExternalLibrary Path="SecondAddin.dll" />
</DnaLibrary>

Then your call from SecondAddin.dll to the FirstAddin.dll will work
fine.

Otherwise, SecondAddin should work fine if it is compiled with a
reference to FirstAddin.dll, and if FirstAddin.dll is in the same
directory as SecondAddIn.xll.
If you want to tell Excel-DNA to find FirstAddIn.dll elsewhere, you
can add a <Reference Path="C:\CompletePath\FirstAddIn.dll" /> into the
SecondAddIn.dna file.
To pack FirstAddIn.dll into SecondAddIn.xll, you are doing the right
thing - you just need the upper-case 'Pack' attribute.


[AFAIK, extension methods are resolved at compile time, so that's not
likely to be the issue.]

-Govert

Homero

unread,
Feb 16, 2011, 7:50:52 AM2/16/11
to Excel-DNA
Hi Govert,

thanks for your time and attention.

I discovered that I was forgetting to put some other dll's (to which
FirstAddIn made reference) in the same directory as SecondAddIn.xll .

Homero
Reply all
Reply to author
Forward
0 new messages