Error when attempting to pack extra dependencies

51 views
Skip to first unread message

Jérémy CHANUT

unread,
Jul 10, 2025, 4:36:31 PMJul 10
to Excel-DNA
Hi there !

I'm creating a simple (let's call it MyAddin), I pack it using ExcelDnaPack.exe, and I'm able to use this addin by double clicking the MyAddin-packed.xll. So far so good.

Now, for further work, I need to use another lib for this addin (let's call it SomeTool).
I have the file SomeTool.nupkg in my project folder, and I register it as a reference package in my .csproj :

  <ItemGroup>
    <PackageReference Include="SomeTool" Version="1.0.4" />
  </ItemGroup>


The thing is, SomeTool comes with its own dependencies, namely:
  • Microsoft.Extensions.DependencyInjection.Abstractions.dll
  • Microsoft.Extensions.DependencyInjection.dll
  • Microsoft.Extensions.Logging.Abstractions.dll
  • Microsoft.Extensions.Logging.dll
  • Microsoft.Extensions.Options.dll
  • Microsoft.Extensions.Primitives.dll
And in order for my addin to work properly locally, I need to copy/paste all those DLLs into the output folder, next to MyAddin.dll, MyAddin-Addin64.dna, and MyAddin-Addin64.xll. And that works.

The problem is that I would like to pack all those dependencies with the rest into  MyAddin-packed.xll (as it seems to be the case for ExcelDna.Integration.dll), so it is easier to distribute to the users.

To that end, I added this to the  .dna file:
<ExternalLibrary Path="MyAddin.dll" Pack="true" />

        <!-- Those extra lines : -->
<ExternalLibrary Path="Microsoft.Extensions.DependencyInjection.Abstractions.dll" Pack="true" />
<ExternalLibrary Path="Microsoft.Extensions.DependencyInjection.dll" Pack="true" />
<ExternalLibrary Path="Microsoft.Extensions.Logging.Abstractions.dll" Pack="true" />
<ExternalLibrary Path="Microsoft.Extensions.Logging.dll" Pack="true"/>
<ExternalLibrary Path="Microsoft.Extensions.Options.dll" Pack="true"/>
<ExternalLibrary Path="Microsoft.Extensions.Primitives.dll" Pack="true"/>
<ExternalLibrary Path="SomeTool.dll" Pack="true" />

And the packing seems to be ok:
7>PackProgram: Using base add-in ...\MyAddin.xll
7>PackProgram:   ~~> ExternalLibrary path  MyAddin  .dll resolved to ...\ MyAddin  .dll.
7>PackProgram:   ~~> ExternalLibrary path Microsoft.Extensions.DependencyInjection.Abstractions.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.DependencyInjection.Abstractions.dll.
7>PackProgram:   ~~> ExternalLibrary path Microsoft.Extensions.DependencyInjection.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.DependencyInjection.dll.
7>PackProgram:   ~~> ExternalLibrary path Microsoft.Extensions.Logging.Abstractions.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.Logging.Abstractions.dll.
7>PackProgram:   ~~> ExternalLibrary path Microsoft.Extensions.Logging.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.Logging.dll.
7>PackProgram:   ~~> ExternalLibrary path Microsoft.Extensions.Options.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.Options.dll.
7>PackProgram:   ~~> ExternalLibrary path Microsoft.Extensions.Primitives.dll resolved to ...\bin\x64\Debug\net8.0-windows\Microsoft.Extensions.Primitives.dll.
7>PackProgram:   ~~> ExternalLibrary path Office.dll resolved to ...\bin\x64\Debug\net8.0-windows\Office.dll.
7>PackProgram:   ~~> ExternalLibrary path SomeTool.dll resolved to ...\bin\x64\Debug\net8.0-windows\MidwayClientSuiteLibraryDotNet.dll.
7>PackProgram:   ->  Updating resource: Type: DNA, Name: __MAIN__, Length: 3282
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.PRIMITIVES, Length: 19908
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.LOGGING, Length: 22875
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: SOMETOOL, Length: 14984
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: MYADDIN, Length: 17272
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.DEPENDENCYINJECTION.ABSTRACTIONS, Length: 24809
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.OPTIONS, Length: 25655
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.LOGGING.ABSTRACTIONS, Length: 26174
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: MICROSOFT.EXTENSIONS.DEPENDENCYINJECTION, Length: 37365
7>PackProgram:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: OFFICE, Length: 95642
7>PackProgram: Completed Packing

But then when running the addin I get this on start :
Initialization [Error] No objects loaded from Microsoft.Extensions.DependencyInjection, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from Microsoft.Extensions.Logging, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from Microsoft.Extensions.Options, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from Microsoft.Extensions.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Initialization [Error] No objects loaded from office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
Initialization [Error] No objects loaded from SomeTool, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null


(Interesting to note that Microsoft.Extensions.DependencyInjection.Abstractions is the only one not causing errors).

And of course the addin doesn't work (the extra tab on the ribbon won't even show).

What am I doing wrong/forgetting here ?

Thanks ! ^_^

Govert van Drimmelen

unread,
Jul 10, 2025, 5:25:15 PMJul 10
to exce...@googlegroups.com

Hi Jeremy,

 

If you were able to use the NuGet package, and since you’re targeting .NET 8, the dependencies would be found from the .deps.json file, and packaged as part of the NuGet build step.

 

If you have to use ExcelDnaPack.exe independently, and manage your own .dna file, you just have to change the extra dependencies to <Reference> tags instead of <ExternalLibrary> tags.

When loading, Excel-DNA looks for functions, ribbons etc. in the <ExternalLibrary> assemblies, but just uses the <Reference> assemblies as additional references.

 

-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 view this discussion visit https://groups.google.com/d/msgid/exceldna/d7d4f50d-7373-4cf5-8a34-a4d33f5659ban%40googlegroups.com.

Jérémy Chanut

unread,
Jul 10, 2025, 5:55:07 PMJul 10
to exce...@googlegroups.com
So my errors were caused just because I used externalLibrary instead of reference?

Govert van Drimmelen

unread,
Jul 10, 2025, 5:56:31 PMJul 10
to exce...@googlegroups.com

It explains the messages, but might not explain why your add-in is not working.

Jérémy CHANUT

unread,
Jul 11, 2025, 9:54:27 AMJul 11
to Excel-DNA
It seems it did the trick, thanks a lot !
Reply all
Reply to author
Forward
0 new messages